This question is an exact duplicate:
var per = {}; per.age = 25; var key = 'age'; console.log(per[key]) // будет правильно var person = {}; person.age = 25; var key = age; console.log(person[key]) // будет ошибка This question is an exact duplicate:
var per = {}; per.age = 25; var key = 'age'; console.log(per[key]) // будет правильно var person = {}; person.age = 25; var key = age; console.log(person[key]) // будет ошибка This question has been marked as a duplicate of an existing one.
Error here:
var key = age; The variable age not declared.
undefined . There is none at all. This is the mistake. "Wrap the string" - hmm, there is no "wrapping" here. - Igorage will be the string value "age" . - IgorSource: https://ru.stackoverflow.com/questions/925898/
All Articles