I've seen these snippet in the polyfill shown on this MDN-documentation:
// Casts the value of the variable to a number.
// So far I understand it ...
count = +count;
// ... and here my understanding ends.
if (count != count) {
count = 0;
}
I got no idea about the purpose.
How can something be unequal itself?
In JavaScript NaN is the only value that's not equal to itself. So that's a check for NaN.
This is the test when count is NaN
because only NaN != NaN
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With