Cannot access property via dot notation javascript -


this question has answer here:

var obj = {a:1,b:2}; var str = "a";  console.log(obj.str); 

this outputs undefined. missing here ?

you need use []

var obj = {a:1,b:2}; var str = "a";  console.log(obj[str]); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -