Skip to content

Instantly share code, notes, and snippets.

@lukeasrodgers
Last active December 16, 2015 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukeasrodgers/5413141 to your computer and use it in GitHub Desktop.
Save lukeasrodgers/5413141 to your computer and use it in GitHub Desktop.
Helper to determine the constructor for an instance, given a namesapce
var constructor_getter = (function() {
var parser = function(ns, instance) {
for (var key in ns) {
try {
if (instance instanceof ns[key]) {
return key;
}
} catch (err) {}
}
};
return function(ns, instance) {
console.log(parser(ns, instance));
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment