I think a code sample is going to work a lot better than my vocabulary:
var keys = ['folder','name'];
var data = { folder: { name: 'Special Folder' } };
Given the two vars above, I'm looking for a way to dynamically use the array as a way to look up the object keys (sort of like a "path"). So I need to programmatically produce the following:
data['folder']['name'] // that would give me 'Special Folder'
Hopefully this makes sense, I just can't quite put all the pieces together.
TIA
(target || {})
totarget
if you want it to throw an error for a set of keys it can't resolve. – Hey Dec 31 '14 at 7:33reduce
would make more sense: jsfiddle.net/5ftkcbpe/1 – Hey Dec 31 '14 at 7:43