So why I can't access the array property by array[0].obj.accessible ?
var array = [{
option1 : '',
option2 : '',
option3 : '',
TEST : {
accessible : '',
optional : ''
},
TEST2 : {
accessible : '',
optional : ''
},
TEST3 : {
accessible : '',
optional : ''
}
}];
function updateArray(obj, acc, opt) {
// this is not working - why?
//array[0].obj.accessible = acc;
//array[0].obj.optional = opt;
// this is working fine:
array[0].option1 = 'option1';
// or this:
array[0].TEST.accessible = acc;
// so why array[0].obj is not refer to 'TEST' ? (obj = 'TEST')
// cause I don't want to build the function updateArray X times with array[0].TEST.accessible, array[0].TEST2.accessible, array[0].TEST3.accessible, etc.
}
updateArray('TEST', 'yes', 'true');
console.log(array);