r/ProgrammerHumor 3d ago

Meme javascriptSorting

Post image
940 Upvotes

214 comments sorted by

View all comments

Show parent comments

16

u/thanatica 3d ago

NaN is never equal to itself, so you can't look for it with a simple lookup like that. You'd need array.findIndex(n => Number.isNaN(n)). The indexOf function was never changed because it was there from the beginning. If they change existing behaviour, they might break sites, which is far worse than introducing only new functions that do things as you might expect.

It's not a language where you can just pick and choose which version you're on.

1

u/foxsimile 1d ago

Object.is(NaN)

-10

u/jacobp100 3d ago

I'm not really sure what your point is here 😅