This commit is contained in:
Ilya Kantor 2017-11-01 12:57:29 +03:00
parent ccc0e9327f
commit 973810d980
6 changed files with 8 additions and 1 deletions

View file

@ -231,6 +231,13 @@ 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.
Also, a very minor difference of `include` is that it correctly handles `NaN`, unlike `indexOf/lastIndexOf`:
```js run
const arr = [NaN];
alert( arr.indexOf(NaN) ); // -1 (should be 0, but === equality doesn't work for NaN)
alert( arr.includes(NaN) );// true (correct)
```
### find and findIndex
@ -703,7 +710,7 @@ A cheatsheet of array methods:
- Additionally:
- `Array.isArray(arr)` checks `arr` for being an array.
Of all these methods only `sort`, `reverse` and `splice` modify the array itself, the other ones only return a value.
Please note that methods `sort`, `reverse` and `splice` modify the array itself.
These methods are the most used ones, they cover 99% of use cases. But there are few others:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 105 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 KiB

After

Width:  |  Height:  |  Size: 307 KiB

Before After
Before After

Binary file not shown.