minor fixes

This commit is contained in:
Ilya Kantor 2022-06-13 23:49:14 +02:00
parent c028189aba
commit bebcbfa134

View file

@ -260,14 +260,15 @@ Note that the methods use `===` comparison. So, if we look for `false`, it finds
If we want to check for inclusion, and don't want to know the exact index, then `arr.includes` is preferred. If we want to check for inclusion, and don't want to know the exact index, then `arr.includes` is preferred.
Also, a very minor difference of `includes` is that it correctly handles `NaN`, unlike `indexOf/lastIndexOf`: Also, a minor, but noteworthy feature of `includes` is that it correctly handles `NaN`, unlike `indexOf/lastIndexOf`:
```js run ```js run
const arr = [NaN]; const arr = [NaN];
alert( arr.indexOf(NaN) ); // -1 (should be 0, but === equality doesn't work for NaN) alert( arr.indexOf(NaN) ); // -1 (should be 0, but equality test === doesn't work for NaN)
alert( arr.includes(NaN) );// true (correct) alert( arr.includes(NaN) );// true (correct)
``` ```
### find and findIndex ### find and findIndex
Imagine we have an array of objects. How do we find an object with the specific condition? Imagine we have an array of objects. How do we find an object with the specific condition?