Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created August 25, 2012 00:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pamelafox/3457998 to your computer and use it in GitHub Desktop.
Save pamelafox/3457998 to your computer and use it in GitHub Desktop.
isDefined
// isDefined(window, 'google');
// isDefined(window, 'google.maps.places');
var isDefined = function(parent, name) {
var parts = name.split('.');
var part = parts.shift();
var cur = parent;
while (part) {
if (cur[part]) {
cur = cur[part];
part = parts.shift();
} else {
cur = null;
part = null;
}
}
return cur !== null;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment