@@ -848,6 +848,7 @@ const letters = ['a', 'b', 'c'];
848848
849849The following are some of the most commonly used array methods in JavaScript:
850850
851+ - **at()**
851852- **concat()**
852853- **constructor**
853854- **copyWithin()**
@@ -857,6 +858,10 @@ The following are some of the most commonly used array methods in JavaScript:
857858- **filter()**
858859- **find()**
859860- **findIndex()**
861+ - **findLast()**
862+ - **findLastIndex()**
863+ - **flat()**
864+ - **flatMap()**
860865- **forEach()**
861866- **from()**
862867- **includes()**
@@ -871,9 +876,33 @@ The following are some of the most commonly used array methods in JavaScript:
871876- **prototype**
872877- **push()**
873878- **reduce()**
879+ - **reduceRight()**
880+ - **reverse()**
881+ - **shift()**
882+ - **slice()**
883+ - **some()**
884+ - **sort()**
885+ - **splice()**
886+ - **toLocaleString()**
887+ - **toReversed()**
888+ - **toSorted()**
889+ - **toSpliced()**
890+ - **toString()**
891+ - **unshift()**
892+ - **valueOf()**
893+ - **values()**
894+ - **with()**
874895
875896[Back to Top⤴️](#table-of-contents)
876897
898+ **at()** - Returns the element at a specified index in an array
899+
900+ ` ` ` javascript
901+ let array = [' a' , ' b' , ' c' ];
902+
903+ console .log (array .at (1 )); // Output: "b"
904+ ` ` `
905+
877906**concat()** - Joins arrays and returns an array with the joined arrays.
878907
879908` ` ` javascript
@@ -973,8 +1002,52 @@ console.log(array); // Output: [1, 2, 3, 4, 5]
9731002console .log (index); // Output: 3
9741003` ` `
9751004
1005+ **findLast()** - Returns the value of the last element in an array that pass a test
1006+
1007+ ` ` ` javascript
1008+ let array = [1 , 2 , 3 , 4 , 5 ];
1009+
1010+ let value = array .findLast (value => value > 3 );
1011+
1012+ console .log (array); // Output: [1, 2, 3, 4, 5]
1013+ console .log (value); // Output: 5
1014+ ` ` `
1015+
1016+ **findLastIndex()** - Returns the index of the last element in an array that pass a test
1017+
1018+ ` ` ` javascript
1019+ let array = [1 , 2 , 3 , 4 , 5 ];
1020+
1021+ let index = array .findLastIndex (value => value > 3 );
1022+
1023+ console .log (array); // Output: [1, 2, 3, 4, 5]
1024+ console .log (index); // Output: 4
1025+ ` ` `
1026+
9761027[Back to Top⤴️](#table-of-contents)
9771028
1029+ **flat()** - Flattens an array up to a specified depth
1030+
1031+ ` ` ` javascript
1032+ let array = [1 , 2 , [3 , 4 , [5 , 6 ]]];
1033+
1034+ let newArray = array .flat (2 );
1035+
1036+ console .log (array); // Output: [1, 2, [3, 4, [5, 6]]]
1037+ console .log (newArray); // Output: [1, 2, 3, 4, 5, 6]
1038+ ` ` `
1039+
1040+ **flatMap()** - Maps each element using a mapping function, then flattens the result into a new array
1041+
1042+ ` ` ` javascript
1043+ let array = [1 , 2 , 3 , 4 , 5 ];
1044+
1045+ let newArray = array .flatMap (value => [value * 2 ]);
1046+
1047+ console .log (array); // Output: [1, 2, 3, 4, 5]
1048+ console .log (newArray); // Output: [2, 4, 6, 8, 10]
1049+ ` ` `
1050+
9781051**forEach()** - Calls a function for each array element
9791052
9801053` ` ` javascript
@@ -1224,6 +1297,49 @@ array.splice(2, 0, 'x', 'y');
12241297console .log (array); // Output: ["a", "b", "x", "y", "c", "d", "e", "f"]
12251298` ` `
12261299
1300+ **toLocaleString()** - Converts an array to a string, using locale-specific settings
1301+
1302+ ` ` ` javascript
1303+ let array = [' a' , ' b' , ' c' ];
1304+
1305+ console .log (array .toLocaleString ()); // Output: "a,b,c"
1306+ ` ` `
1307+
1308+ **toReversed()** - Reverses the elements of an array
1309+
1310+ ` ` ` javascript
1311+ let array = [' a' , ' b' , ' c' ];
1312+
1313+ let reversedArray = array .toReversed ();
1314+
1315+ console .log (array); // Output: ["a", "b", "c"]
1316+ console .log (reversedArray); // Output: ["c", "b", "a"]
1317+ ` ` `
1318+
1319+ [Back to Top⤴️](#table-of-contents)
1320+
1321+ **toSorted()** - Sorts the elements of an array
1322+
1323+ ` ` ` javascript
1324+ let array = [3 , 1 , 4 , 1 , 5 , 9 , 2 , 6 , 5 , 3 , 5 ];
1325+
1326+ let sortedArray = array .toSorted ();
1327+
1328+ console .log (array); // Output: [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]
1329+ console .log (sortedArray); // Output: [1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9]
1330+ ` ` `
1331+
1332+ **toSpliced()** - Adds/Removes elements from an array
1333+
1334+ ` ` ` javascript
1335+ let array = [' a' , ' b' , ' c' , ' d' , ' e' , ' f' ];
1336+
1337+ let splicedArray = array .toSpliced (2 , 0 , ' x' , ' y' );
1338+
1339+ console .log (array); // Output: ["a", "b", "c", "d", "e", "f"]
1340+ console .log (splicedArray); // Output: ["a", "b", "x", "y", "c", "d", "e", "f"]
1341+ ` ` `
1342+
12271343**toString()** - Converts an array to a string, and returns the result
12281344
12291345` ` ` javascript
@@ -1252,6 +1368,28 @@ let array = ['a', 'b', 'c'];
12521368console .log (array .valueOf ()); // Output: ["a", "b", "c"]
12531369` ` `
12541370
1371+ **values()** - Returns an Array Iteration Object, containing the values of the original array
1372+
1373+ ` ` ` javascript
1374+ let array = [' a' , ' b' , ' c' ];
1375+
1376+ let iterator = array .values ();
1377+
1378+ console .log (array); // Output: ["a", "b", "c"]
1379+ console .log (iterator .next ().value ); // Output: "a"
1380+ ` ` `
1381+
1382+ **with()** - Allows you to add properties and methods to an Array object
1383+
1384+ ` ` ` javascript
1385+ let array = [' a' , ' b' , ' c' ];
1386+
1387+ Array .with = 25 ;
1388+
1389+ console .log (array); // Output: ["a", "b", "c"]
1390+ console .log (Array .with ); // Output: 25
1391+ ` ` `
1392+
12551393[Back to Top⤴️](#table-of-contents)
12561394
12571395## Strings
0 commit comments