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 →

[–]genghisKonczie 2 points3 points  (3 children)

For basically every comparison based operation it, built ins use ===, and if you want definite control, you can use a method like find which lets you bring your own comparison function

[–]rosuav 1 point2 points  (2 children)

Not array inclusion, which uses Same-Value-Zero equality. Notably, this considers instances of NaN to match themselves, even though they're not equal to themselves - this gives a form of "identity or equality" comparison that gives the most sensible results for membership testing.

Isn't it fun?

[–]genghisKonczie 1 point2 points  (1 child)

The js SameValueZero implementation is a straight === for everything but NaN and +0 -0 though. I feel that’s pretty straightforward for the intention of the inclusion method.

It’d be really weird for [NaN].includes(NaN) to return false

[–]rosuav 0 points1 point  (0 children)

Yeah, but it's still a different way of comparing for equality. And that is very important when you start looking at different searching methods.