Is there a more efficient way for instances of a class to keep track of how many have been created? Each instance should inherently know its own position in the group.
I initially considered using global variables, but I suspect there might be a better solution out there.
Here's an example of what I want to avoid:
class MyClass {
this.instanceId = (window.instanceCount == undefined) ? 0 : window.instanceCount + 1;
window.instanceCount = this.instanceId;
...
}