How does Javascript associative array work? -
i in bit of puzzle, had worked on project use of javascript necessary. working fine need know how work
eg : had dynamic variable count
, use value, lets value var count = 6;
now when put in array {count : count }
output {count : 6}
now doubt output should have been { 6 : 6}
count should have been replaced value didn't happen so. why happening ? , how working ?
the key value pairs treat key literal , value variable.
so:
var count = 6; var o = {count: count}; // results in {count: 6}
but use variable key, can this:
var count = 6; var o = {}; o[count] = count; // results in: {6: 6}
Comments
Post a Comment