var a = 0;
jsonArr = [{
   "count" : a
}]
a = 10;
console.log(jsonArr[0].count) 
This doesn't update my JSON values, is there a solution or JSON objects allow no references?
var a = 0;
jsonArr = [{
   "count" : a
}]
a = 10;
console.log(jsonArr[0].count) 
This doesn't update my JSON values, is there a solution or JSON objects allow no references?
The json.count variable gets assigned to the value of 0, as 0 is a number, and numbers are primitives.
If you used a non-primitive type then the object would hold the reference and the code would work as expected if you edited the object you are referencing.
Just re-assigning a to a different variable will replace that reference in a, pointing to a different object.
See this tutorial for more info on primitives vs non-primitives and by-value vs by-reference, or this example for code that works how you are expecting.
