How can I use the value of the variable a as a key to lookup a property? I want to be able to say: b[\"whatever\"] and have this return 20:
a
b[\"whatever\"]
var a = "whatever"; var b = {a : 20}; b[a] = 37; alert(b["whatever"]); // 37
'a' is a string with the value 'a'. a is a variable with the value 'whatever'.
'a'
'whatever'