I am going to set property of html objects.
var property1 = \'style.visibility\';
var property2 = \'style.display\';
var property3 = \'style\';
You can create function using reduce()
to access nested properties.
var property1 = 'style.visibility';
var property2 = 'style.display';
var property3 = 'style';
var obj = {style: {visibility: 1, display: 2}}
function getProp(prop, obj) {
return prop.split('.').reduce(function(r, e) {
return r[e]
}, obj)
}
console.log(getProp(property1, obj))
console.log(getProp(property2, obj))
console.log(getProp(property3, obj))