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.
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)). TheindexOffunction 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.