Skip to content

Instantly share code, notes, and snippets.

@dtsn
Created November 9, 2011 15:03
Show Gist options
  • Save dtsn/1351684 to your computer and use it in GitHub Desktop.
Save dtsn/1351684 to your computer and use it in GitHub Desktop.
If you wanted to retrieve the object window.frames.url when you only have a array of string parts ['frames', 'url']
/**
* Will give you the object from a set of arrays
*
* If you wanted to retrieve the object window.frames.url when you only have a array of string parts ['frames', 'url']
*/
function crawl(obj, keys) {
var key = keys.shift();
return keys.length == 0 ? obj[key] : crawl(obj[key], keys);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment