Skip to content

Instantly share code, notes, and snippets.

@JakubOboza
Created February 15, 2012 16:31
Show Gist options
  • Select an option

  • Save JakubOboza/1837120 to your computer and use it in GitHub Desktop.

Select an option

Save JakubOboza/1837120 to your computer and use it in GitHub Desktop.
var u = require('underscore');
var object = {
varun: {
curry: {
rice: {
dan: "green"
}
}
}
};
var props = "varun.curry.rice.dan".split(".");
var result = u.reduce(props, function(current, property){
return current[property];
}, object);
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment