как получить доступ к свойству объекта с помощью переменной [duplicate]
На этот вопрос уже есть ответ:
Динамический доступ к свойству объекта с помощью переменной 11 ответовУ меня есть объект
var Messages = {
'fullName' : 'Tell us your cool name dude..! e.g. Yousuf Iqbal',
'userName' : 'Choose a catchy username. Remember! It should be available :)',
'password' : 'Choose a top secret password with special chars, numbers and alphabets',
'rePassword' : 'Retype the password you just typed. But, don\'t try to copy!',
'bYear' : 'Tell the year, in which this bomb blasted'
};
и переменная ..
var attribute = $('#userinfo form input').attr('name');
сейчас я хочу выбрать свойство объекта Messages, используя эту переменную, как это ..
var message = Messages.attribute;
но это не работает .. и также попробовал следующее ..
var message = Messages+'.'+attribute;