Let's use this object as example:
var obj = {a: {b: {c: 'result'}}}
I know that I can get the value of c, doing this:
console.log(obj.a.b.c) // 'result'
or this:
console.log(obj['a']['b']['c'])
but how I can get the value of c passing obj and columns as arguments in a function?
function func(obj, attributes) {
return obj[attributes]
}
console.log(func(obj, a.b.c)) // how to make this work
console.log(func(obj, ['a']['b']['c'])) // or this