Setting this to null instead of throwing ReferenceError in a derived class' constructor
Brendan Eich
brendan at mozilla.org
Tue Jan 20 14:25:14 PST 2015
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.
/be
More information about the es-discuss
mailing list