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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -