Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aurorapar/23d767859fd860544e2f023653d232f8 to your computer and use it in GitHub Desktop.
Save aurorapar/23d767859fd860544e2f023653d232f8 to your computer and use it in GitHub Desktop.
function checkNested(obj /*, level1, level2, ... levelN*/) {
var args = Array.prototype.slice.call(arguments, 1);
for (var i = 0; i < args.length; i++) {
if (!obj || !obj.hasOwnProperty(args[i])) {
return false;
}
obj = obj[args[i]];
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment