im trying to create my object name dynamically. below is code
var empdept = 'financialDept';
var settings = { empdept :[{
'name' : 'bob',
'sname' : 'the builder',
'age' : '8',
'req' : 'yes'}]
};
so if i want to show the age like this alert(settings.financialDept.age); is not working, but if i have the above snippet code like this
var settings = { 'financialDept' :[{
'name' : 'bob',
'sname' : 'the builder',
'age' : '8',
'req' : 'yes'}]
};
and now if i want to show the age like this alert(settings.financialDept.age);. this one works. please really need help to do it dynamically. any help really appreciated. thanks
Try it like this: