I want to retrieve all objects (not DOM elements) of a given type created with the “new” keyword.
Is it possible ?
function foo(name)
{
this.name = name;
}
var obj = new foo();
How can I retrieve a reference to all the foo objects ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If they were all assigned in the global scope, and you don’t need to check across
iframe/windowboundaries, and you do not need to do this in IE (eg you’re just trying to debug something), you should be able to iterate over the global scope:Buuuuut you probably have some foos instantiated inside functions somewhere, in which case they’re not available.
You can perhaps try modifying the constructor prior to instantiations: