Static methods in OOjs can't know which class they belong to, or which class they're called with (unlike regular methods, which can use this.constructor).
Use case:
- Imagine you have a set of classes, with a common ancestor, that can be serialized to a string and reconstructed from such string.
- You want to implement Animal#serialize and Animal.static.unserialize, and call them like dog = new Dog( … ); string = dog.serialize() and dog = Dog.static.unserialize( string ), and you also want to verify that the passed string actually unserializes to an instance of this class (in this case, Dog and not Cat).
- However, the Animal.static.unserialize method, which is being called here, doesn't know whether it's being called on Dog.static, Cat.static or Animal.static.
You can invent a different API (like dog = Animal.unserialize( string, 'Dog' ), or dog = new Dog().unserialize( string )), but the original one is by far the prettiest.
Do we want to support this? I played with it and it seems simple to provide a class property on static objects, such that Dog.static.class === Dog, which could be accessed as this.class from static methods.