suppose I have {"data": {"243232": {"id": "testid","name": "test" } }}
so when I do
var a = data.243232.id;
alert(a); // it gives me testid.
but when I do like
var c = 243232;
var d = data.c.id;
alert(d) //it gives as undefined.
so how to get correct value when i alert d in above case thanks.
Use the other notation
var a = data['243232'].idRemember all objects in JS are really just associative arrays.
Object keys just a variable in js and thus require proper naming
the variable naming rules are.
(either uppercase or lowercase) or an
underscore (_), or a dollar sign ($).
numbers, underscores, or dollar signs
in JavaScript Variables.
a reserved word of JavaScript, see
details of JavaScript Reserved
Characters
JSON normally uses an eval() function to turn the string into a data-structure. This allows for incorrect keys. If you want to reference an improper key, you need to use the associative array method.
As for you addition
Will work