JSON - Accessing a numeric property

0 votes
added Jul 4, 2018 in API by LC Marshal Captain (25,790 points)
edited Jul 13, 2018 by LC Marshal
var myObject = { '0' : 'blue', 'satu' : 'red' };

//Usually, to access the property with:
myObject.0 //this is usually not working
myObject.satu //this is ok, because its not numeric

//use this instead
(myObject["0"] is an alternative syntax for myObject.0.
lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.