Is it faster to declare complex data in the JSON conform way:
var data = [ {"x":0,"y":3}, {"x":3,"y":4}, {"x":8,"y":0} ];
Or this way :
var data = [ {x:0,y:3}, {x:3,y:4}, {x:8,y:0} ];
I mean is there any Performance difference ?
Is it faster to declare complex data in the JSON conform way:
var data = [ {"x":0,"y":3}, {"x":3,"y":4}, {"x":8,"y":0} ];
Or this way :
var data = [ {x:0,y:3}, {x:3,y:4}, {x:8,y:0} ];
I mean is there any Performance difference ?
Usually if declaring an object var data = [ {x:0,y:3} ]
this way is preferred because it is faster to write and this need less space but not any major performance difference
But consider a situation you want to assign property name to be reserved words or expression
var data = { class : "Oh class" };
var car = { a*b: "aabb" };
in this situation
var data = { "class" : "Oh class" }
var car = { "a*b" : "aabb" };
with quotes is preferred since in some IE without quotes it will give error. So quotes is preferred when you want to use a key that’s not a valid JavaScript identifier
Also, the JSON standard (which is not Javascript) always requires double-quotes.