Skip to content

Comment on Anders Hejlsberg on Modern Compiler Construction (2016) [video]parent

Comments

er - no. Assuming you are not trolling (benefit of the doubt and all that):

You might mean it shouldn't work? but alas it does (because of 'lopsided equality tables'). Try the following: open the console of your browser, type the following:

true == 1 === true

and press enter - tada! You can also check out this SO answer if you are sufficiently flabbergasted: https://stackoverflow.com/a/12236341

I'm not sure how what you linked is related, but the only "surprising" thing here is probably `true == 1`. This evaluates to true, and because comparisons are left-associative, we have `(true == 1) === true` which reduces to `true === true`, which, unsurprisingly, is true.

Agree. It was my point. `true 0== 1` resolves to true, but shouldn't so `true == 1 === true` should be false but is true, which could at the very least be called ambiguous to people not familiar with the language. It may reflect somewhat badly on Brendan since they felt compelled to introduce === to rectify this. Personally I think it made the language richer, with more options to chose from depending on circumstance, and it was more like an adaption to the new uses for js.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.