Working on re-implementing lodash, and discovered this expression in their comparator function:
var valIsReflexive = value === value; // um.. WTH is THAT ^^^^^^^^
Not understanding why there were two separate "equals" statements (the first as an assignment, and the second as a strict equality operator), I asked my friend Lindsey for help. She explained that the '===' is making a comparison, and the value of the comparison,
value === value (true or false), is then stored in the variable,
Which then begs the question, when would
value === value ever evalute to false?
So back to Stack Overflow I went, and eventally landed here.
And that's where I learned that
NaN is, like, totally crazypants. I ran a few tests in my code, to confirm this; results below.
console.log(NaN===NaN); // false console.log(3/0===4/0); // true
And then, I was like, "WAT." (You should totally watch that, btw. Gary Bernhardt === GOLD.) But then fnenu asked, "What if you set those values to variables, does it still evaluate to false?" This is an excellent question, so I ran another test:
var wat = NaN; var waat = NaN; console.log(wat===waat); // false console.log(wat===wat); // false <-- I KNOW, RIGHT?!
GAH. Mind, bent.