How to assign the value to the JSON by providing the index for it..
see the following code,
var jsonVariable = [];
jsonVariable[10] = {1:10};
alert(jsonVariable.toSource());
For the above code the output is,
[,,,,,,,,,{1:10}]
The output i expect and i need is [10 : {1:10}]
How to code to bring the output as i expect… please help me briefly..
You used index-operators (
[]), which instanciate anew arrayand set the element at index 10 to{1: 10}. You actually wanted to use curly braces operators ({}) which instanciate anew objectand ad a property10: {1:10}like that:Setting members to an
array, you can’t simply skip some indices (begin at 10). All uninstaciated indices until yours will forcible be created.