I thought there would already be an answer for this but I can't seem to find one..
This has to be done in a situation where I do not know the names of the instances.
I think I could use some sort of static variable inside my class to store all instances, but this doesn't seem to exist in JS
So how to call my method on all existing instances of my class?
Note : just for clarification : I'm not speaking about CSS classes, I'm speaking about objects.
var instance = new something();
You can create a static array and store it on your constructor function:
MyClass.allInstances = ; MyClass.allInstances.push(this);
However, you need some way to figure out when to remove instances from this array, or you'll leak memory.