20.08.2014, 19:18, "Claude Pache" <[email protected]>:
> Le 20 août 2014 à 16:56, Alex Kocharin <[email protected]> a écrit :
>>  But... why?
>>
>>  I mean, every constructor can determine if it is called without `new` (that 
>> "this instanceof" check on top of every other constructor). So `new` keyword 
>> can really be removed from everywhere except in constructors themselves.
>>
>>  Using `new` does create issues. For example, you can't write "new 
>> require('something').Constructor(blah)", and I don't even remember how to 
>> put brackets right.
>>
>>  Why make people use it?
>
> According to http://esdiscuss.org/notes/2013-07-25 (search for 
> "anti-pattern"), allowing constructors without `new` would break subclassing.

Still doesn't make much sense... This pattern (this instanceof ...) breaks 
another pattern (BaseClass.call(this)). Why first one is deprecated, not the 
second one?

I mean, I was able to subclass such a class with prototype injection without 
any issues, and it feels more natural in javascript after all.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to