This indirection doesn't appear to be necessary. It looks like there may've been
some confusion between the prototype object of a class, vs of an object.
The "prototype of an object" refers to the parent object that a given object
inherits from (retrieved via JS_GetPrototype in cpp, or Object.getPrototypeOf(obj)
in ES5). This should be rare in a codebase that mimics classical inheritance.
The "prototype of a class" is informal concept that refers to the object that
newly constructed instances will be inheriting from. Eg function makeFoo() might
spawn objects that inherit from FooBase (their prototype). The new operator
provides syntax-sugar that connects the constructor function with the parent
object for its instance, with the convention that the base object is stored
at "MyConstructor.prototype". The new operator basically just does
obj = Object.create(Ctor.prototype); Ctor.call(obj);. Bottom line is:
"Ctor.prototype" is the prototype of Ctor objects, not of the "Ctor" function.
Instead of storing "Vector2D.prototype" as its own global variable that we
access, access "Vector2D" instead, and then access "prototype" as property
of that. Also, remove the three manual steps (discovery of prototype property,
creating an object from it, and setting its properties), in favour of letting
SpiderMonkey and the vector.js do this.