How to fix the `class` keyword

Jorge jorge at jorgechamorro.com
Wed Mar 4 19:43:15 UTC 2015


On 04/03/2015, at 20:13, Matthew Robb wrote:

> Making the following two things no longer interchangeable completely breaks my mental model for JS:
> ```
> var x = new X;
> ```
> and
> ```
> var x = {}; X.call(x);
> ```

This has never been the same and it isn't interchangeable. In one case the prototype is X.prototype and in the other it's Object.prototype.

Have you never seen this line in constructors?

if ( !( this instanceof X ) ) return new X(a.copy.of.the.arguments.goes.here);

-- 
( Jorge )();



More information about the es-discuss mailing list