Prototypes as the new class declaration

Axel Rauschmayer axel at rauschma.de
Mon Jun 20 04:12:05 PDT 2011


>>> correct, whatever magic there is occurs as part of defining a "constructor" property as part of an object literal.  However, such things could still be wired up manually (most likely by somebody wanting to create procedural abstractions for class-like definitions.
>> 
>> Are you thinking along the lines of the following example?
>>     var MyClass = class({ ... });
> 
> no, referring back to the example in my post that started this thread:
> 
>> const SkinnedMesh = THREE.Mesh <| {
>>   constructor(geometry, materials) {
>>     super.constructor(geometry, materials);
>>  
>>     this.identityMatrix = new THREE.Matrix4();
>>     this.bones = [];
>>     this.boneMatrices = [];
>>     ...
>>   }, 
>>   update(camera) {
>>     ...
>>     super.update();
>>   }
>> }
> the "constructor" function defined above would  be automatically created with a "prototype" property whose value is the containing object created by the object literal.  Put another way:           
>      SkinnedMesh.constructor.prototype===SkinnedMesh
> would evaluate to true

I was referring to “such things could still be wired up manually”. Where would the manual wiring occur?

-- 
Dr. Axel Rauschmayer

axel at rauschma.de
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com





More information about the es-discuss mailing list