var give = \'i.want.it\'; var obj = { i: { want: { it: \'Oh I know you do...\' } } }; console.log(obj[give]); // \'Oh I know yo
Use Array#reduce() method
var give = 'i.want.it'; var obj = { i: { want: { it: 'Oh I know you do...' } } }; var res = give.split('.').reduce(function(o, k) { return o && o[k]; }, obj); console.log(res);