javascript - Defining "path" to object key with a string -


this question has answer here:

is possible define "path" object key?

for instance if have object:

var obj = {     hello: {         you: "you"     } } 

i select this:

var path = "hello.you"; obj[path]; //should return "you" 

(doesn't work obviously, there way?)

you can try this:

var path = "hello.you"; eval("obj."+path); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -