7 ms·
Only thing I am not sure about is the focus on "===" - I think it is a pain and fails in too many instances to do what the programmer would expect.
by bdfh42 15y ago
Only thing I am not sure about is the focus on "===" - I think it is a pain and fails in too many instances to do what the programmer would expect.
- OriginalSyn 15y agoStrict Equals Operator (===) does exactly what I expect and that is no funny coercion or guessing, two objects I'm evaluating have a 1 for 1 likeness, no more no less. How is that confusing?
- ryanbraganza 15y agoNaN !== NaN Apart from that, I agree.
- OriginalSyn 15y agoSure but at least the spec is clear that NaN always returns false.
- jQueryIsAwesome 15y agoThat is the reason for the existence of the function isNaN. Plus, NaN returns a generated object, so that result is expected ({}) !== ({})
- tikhonj 15y agoThat's not really language dependent--that's how floating point numbers always work. And with good reason--there are actually a ton of different NaN bit patterns in the floating point standard. I think anything where the exponent is all 1 is an NaN (except maybe for infinity--I don't remember the exact details). The point is that two completely different patterns of bits can be NaN.
- ricardobeat 15y agoThere is nothing unexpected in strict equals behavior, quite the opposite. This is unexpected for most: '[object Object]' == {}
- city41 15y agoCan you give examples of it doing unexpected things? I get the feeling the unexpected part about it is your operands are not of the types you thought they were?
- deleted 15y ago[deleted]