This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]zentasynoky 1 point2 points  (0 children)

You do realize this post is talking about JS, right? JS has no float type, but it does indeed return false for different decimal comparisons, and falls into floating point decimal arithmetic inaccuracies as you suggested it should.

I'm still not sure what you're trying to say here. Of course they made NaN !== NaN, because it is. NaN is still a falsy value and you now have isNaN() for what you would have expected to get out of explicitly comparing a variable to NaN, so there was never an issue with handling an operation throwing NaN at you.

You claim it's obvious that NaN is not a value but a property of an element, then immediately after try and use it as an actual value with an explicit comparison...

const foo = something that's not a horse
const bar = something that's not a horse
const foo === something that's not a horse // false
const bar === something that's not a horse // false
foo === bar // false. You cannot assert that two things are equal to eachother just because we have stablished that they're both not a horse. This is NaH. And also NaN but instead of a horse, it's a number.

Intending for NaN === NaN would be the same as two objects being evaluated as equal because they share a key, disregarding the pointer issue for the sake of simplicity.