var give = \'i.want.it\';
var obj = {
i: {
want: {
it: \'Oh I know you do...\'
}
}
};
console.log(obj[give]); // \'Oh I know yo
make it
var obj = {
i: {
want: {
it: 'Oh I know you do...'
}
}
};
//var result = JSON.parse(JSON.stringify(obj)); //cloning the existing obj
var result = obj; //cloning the existing obj
var give = 'i.want.it';
//now split the give and iterate through keys
give.split(".").forEach(function(key){
result = result[key];
});
console.log(result);