You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ne/arrays/README.md
+1-46Lines changed: 1 addition & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,33 +1,23 @@
1
-
# Arrays (рдПрд░реЗ)
2
-
3
-
Arrays are a fundamental part of programming. An array is a list of data. We can store a lot of data in one variable, which makes our code more readable and easier to understand. It also makes it much easier to perform functions on related data.
constcars= ["Saab", "Volvo", "BMW"]; // using array literals
26
18
constcars=newArray("Saab", "Volvo", "BMW"); // using the new keyword
27
19
```
28
20
29
-
An index number is used to access the values of an array. The index of the first element in an array is always `0` as array indexes start with `0`. The index number can also be used to change the elements of an array.
|`concat()`| Returns two or more combined arrays |
56
-
|`join()`| Joins all elements in an array into a string |
57
-
|`push()`| Adds one or more elements at the end of the array and returns the length |
58
-
|`pop()`| Removes the last element of an array and returns that element |
59
-
|`shift()`| Removes the first element of an array and returns that element |
60
-
|`unshift()`| Adds one or more elements at the front of an array and returns the length |
61
-
|`slice()`| Extracts the section of an array and returns the new array |
62
-
|`at()`| Returns element at the specified index or `undefined`|
63
-
|`splice()`| Removes elements from an array and (optionally) replaces them, and returns the array |
64
-
|`reverse()`| Transposes the elements of an array and returns a reference to an array |
65
-
|`flat()`| Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth |
66
-
|`sort()`| Sorts the elements of an array in place, and returns a reference to the array |
67
-
|`indexOf()`| Returns the index of the first match of the search element |
68
-
|`lastIndexOf()`| Returns the index of the last match of the search element |
69
-
|`forEach()`| Executes a callback in each element of an array and returns undefined |
70
-
|`map()`| Returns a new array with a return value from executing `callback` on every array item. |
71
-
|`flatMap()`| Runs `map()` followed by `flat()` of depth 1 |
72
-
|`filter()`| Returns a new array containing the items for which `callback` returned `true`|
73
-
|`find()`| Returns the first item for which `callback` returned `true`|
74
-
|`findLast()`| Returns the last item for which `callback` returned `true`|
75
-
|`findIndex()`| Returns the index of the first item for which `callback` returned `true`|
76
-
|`findLastIndex()`| Returns the index of the last item for which `callback` returned `true`|
77
-
|`every()`| Returns `true` if `callback` returns `true` for every item in the array |
78
-
|`some()`| Returns `true` if `callback` returns `true` for at least one item in the array |
79
-
|`reduce()`| Uses `callback(accumulator, currentValue, currentIndex, array)` for reducing purpose and returns the final value returned by `callback` function |
80
-
|`reduceRight()`| Works similarly lie `reduce()` but starts with the last element |
For example, let's say you have an array of numbers and you want to print the double of each number to the console. You could do this using `forEach` like this:
 `forEach` does not modify the original array. It simply iterates over the elements of the array and executes the provided function for each element.
Copy file name to clipboardExpand all lines: ne/arrays/indices.md
+2-8Lines changed: 2 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,4 @@
1
-
# Indices (рд╕реВрдЪрдХрд╛рдВрдХ)
2
-
3
-
So you have your array of data elements, but what if you want to access a specific element? That is where indices come in. An **index** refers to a spot in the array. indices logically progress one by one, but it should be noted that the first index in an array is 0, as it is in most languages. Brackets `[]` are used to signify you are referring to an index of an array.
Note that if you try to access or set an element using an index that is outside the bounds of the array (i.e., an index that is less than 0 or greater than or equal to the length of the array), you will get an `undefined` value.
Copy file name to clipboardExpand all lines: ne/arrays/join.md
+1-12Lines changed: 1 addition & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,13 @@
1
-
# Join (рд╕рд╛рдореЗрд▓)
2
-
3
-
The `join` method, makes an array turn into a string and joins it all together. It does not change the original array. Here's the syntax for using `join`:
The `separator` argument is optional and specifies the character to be used to separate the elements in the resulting string. If omitted, the array elements are separated with a comma (`,`).
In the above example, a space is used as a separator. You can also use `join` to convert an array-like object (such as an arguments object or a NodeList object) to a string by first converting it to an array using the `Array.prototype.slice()` method:
It's also worth noting that the `length` property is not a method, so you don't need to use parentheses when accessing it. It's simply a property of the array object that you can access like any other object property.
0 commit comments