Merge pull request #3073 from Rnbsov/patch-70

Minor change to array methods article
This commit is contained in:
Ilya Kantor 2022-06-23 10:59:55 +03:00 committed by GitHub
commit 23047ab4ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -676,7 +676,7 @@ So `typeof` does not help to distinguish a plain object from an array:
```js run ```js run
alert(typeof {}); // object alert(typeof {}); // object
alert(typeof []); // same alert(typeof []); // object (same)
``` ```
...But arrays are used so often that there's a special method for that: [Array.isArray(value)](mdn:js/Array/isArray). It returns `true` if the `value` is an array, and `false` otherwise. ...But arrays are used so often that there's a special method for that: [Array.isArray(value)](mdn:js/Array/isArray). It returns `true` if the `value` is an array, and `false` otherwise.
@ -767,7 +767,7 @@ A cheat sheet of array methods:
- `reduce/reduceRight(func, initial)` -- calculate a single value over the array by calling `func` for each element and passing an intermediate result between the calls. - `reduce/reduceRight(func, initial)` -- calculate a single value over the array by calling `func` for each element and passing an intermediate result between the calls.
- Additionally: - Additionally:
- `Array.isArray(arr)` checks `arr` for being an array. - `Array.isArray(value)` checks `value` for being an array, if so return true, otherwise false.
Please note that methods `sort`, `reverse` and `splice` modify the array itself. Please note that methods `sort`, `reverse` and `splice` modify the array itself.