Created
August 14, 2014 09:22
-
-
Save juanparati/e171e04e84b086a2e22f to your computer and use it in GitHub Desktop.
getInstaceOf from the same class, so we can retrieve the var name thas contains the object
This file contains hidden or 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
/** | |
* Get instance names of an object | |
* | |
* Returns instances | |
*/ | |
function getInstancesOf() | |
{ | |
var instances = []; | |
for(var v in window) { | |
if(window.hasOwnProperty(v) && window[v] instanceof PlayerInterface) { | |
instances.push(v); | |
} | |
} | |
return instances; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It comes from:
http://acidmartin.wordpress.com/2012/03/19/getting-instance-names-of-a-javascript-object/