Setting this to null instead of throwing ReferenceError in a derived class' constructor

Dmitry Lomov dslomov at
Wed Jan 21 01:44:41 PST 2015

On Tue, Jan 20, 2015 at 11:25 PM, Brendan Eich <brendan at> wrote:

> Ryosuke Niwa wrote:
>> Having said that, TDZ was introduced to give "let", "const", and alike a
>> sensible behavior as I understand it.  Since "this" was never defined by
>> "let" or "const", it seems a little arbitrary and inconsistent to make
>> "this" TDZ only inside a derived class's constructor.
> It's not arbitrary as in a fair coin toss -- it's intentionally biased to
> catch errors. Using null or undefined would find fewer errors.
> I'm wondering whether other implementors feel the same pain. I mailed a
> few V8 folks asking them, maybe they'll weigh in.

I am not sure why that extra check is considered problematic
We have not yet implemented it in V8 (working on a patch right now!), but a
simple, even syntactic, analysis will probably eliminate checks in 90% of
real use cases. And normal function definitions need no extra checks.
Beyond that, 'this' binding is very similar to 'const' binding indeed, so
we hope that the same analysis we will apply for eliminating checks for
'const' and 'let' would apply for 'this' as well - at least that is the

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list