0

This is working great in PHP, how can I accomplish the same in JS/jQuery?

$statsArr['Status'][$s_id]['count'] = ($statsArr['Status'][$s_id]['count'] ?? 0) + 1;
6

1 Answer 1

1

You have to define each array as an array. Then you won't have the missing ; before statement error.

var s_id = 0;
var statsArr = Array();
statsArr['Status'] = Array();
statsArr['Status'][s_id] = Array();
statsArr['Status'][s_id]['count'] = statsArr['Status'][s_id]['count'] + 1 || 0;
// the result will be 0 since statsArr['Status'][s_id]['count'] was not defined previously
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.