Skip to content

Commit 2cff951

Browse files
authored
Naming improvement
1 parent dde3c1a commit 2cff951

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

1-js/05-data-types/05-array-methods/article.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ The methods [arr.reduce](mdn:js/Array/reduce) and [arr.reduceRight](mdn:js/Array
529529
The syntax is:
530530

531531
```js
532-
let value = arr.reduce(function(previousValue, item, index, arr) {
532+
let value = arr.reduce(function(previousValue, item, index, array) {
533533
// ...
534534
}, initial);
535535
```
@@ -538,7 +538,7 @@ The function is applied to the elements. You may notice the familiar arguments,
538538

539539
- `item` -- is the current array item.
540540
- `index` -- is its position.
541-
- `arr` -- is the array.
541+
- `array` -- is the array.
542542

543543
So far, like `forEach/map`. But there's one more argument:
544544

@@ -613,6 +613,7 @@ So it's advised to always specify the initial value.
613613

614614
The method [arr.reduceRight](mdn:js/Array/reduceRight) does the same, but goes from right to left.
615615

616+
616617
## Array.isArray
617618

618619
Arrays do not form a separate language type. They are based on objects.
@@ -694,6 +695,9 @@ A cheatsheet of array methods:
694695
- `includes(value)` -- returns `true` if the array has `value`, otherwise `false`.
695696
- `find/filter(func)` -- filter elements through the function, return first/all values that make it return `true`.
696697
- `findIndex` is like `find`, but returns the index instead of a value.
698+
699+
- To iterate over elements:
700+
- `forEach(func)` -- calls `func` for every element, does not return anything.
697701

698702
- To transform the array:
699703
- `map(func)` -- creates a new array from results of calling `func` for every element.
@@ -702,9 +706,6 @@ A cheatsheet of array methods:
702706
- `split/join` -- convert a string to array and back.
703707
- `reduce(func, initial)` -- calculate a single value over the array by calling `func` for each element and passing an intermediate result between the calls.
704708

705-
- To iterate over elements:
706-
- `forEach(func)` -- calls `func` for every element, does not return anything.
707-
708709
- Additionally:
709710
- `Array.isArray(arr)` checks `arr` for being an array.
710711

0 commit comments

Comments
 (0)