javascript - Strange object member behaviour with node.js -
currently i'm trying set properties of object using square bracket notation. code follows
var obj = {}; obj['c9c4d17a698ace65c80416112da3ff66e652ec013222f5b458a1dd4950580e77'] = 'one'; obj['8d207abeb95e36abfa2cdae6ac700e776c982ec64bcbfd501cb48fec55a13a77'] = 'two';
if console.log(obj)
or console.dir(obj)
result is
{ c9c4d17a698ace65c80416112da3ff66e652ec013222f5b458a1dd4950580e77: 'one', '8d207abeb95e36abfa2cdae6ac700e776c982ec64bcbfd501cb48fec55a13a77': 'two' }
what want know why 1 property key set unquoted literal , other set string. both being set in same way. falling victim escape sequence within key?
node --version
v0.10.33
on os x yosemite 10.10.1
any time object key starts number, appear quoted when inspected in console.
this doesn't affect internal representation. these keys strings, as-assigned. it's when inspect them, they'll quoted if need (such when contain reserved character or start number).
Comments
Post a Comment