Last active
December 16, 2015 09:29
-
-
Save lukeasrodgers/5413141 to your computer and use it in GitHub Desktop.
Helper to determine the constructor for an instance, given a namesapce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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