I am making a function where i give the object path in a variable. I use this function after i got my data from the database.
function find(object, path, cb) {
return cb(object[path]);
}
var object = {user:{firstname:"bob"}};
find(object, "user", function(data){});
This works fine with objects on the first level of the object but what if i want a object from the second level or higher:
"user.firstname"
When i try to run this through the find function wil it give a not defined error. How can i improve my function?