Skip to content

Commit 91c835e

Browse files
authored
Merge pull request #301 from renatosantosti/master
How to copy an array and reverse it.
2 parents 42b0a18 + 7336f93 commit 91c835e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

JavaScript_Basics/arrays.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,13 @@ languages.slice(1, 3);
8686

8787
languages.slice(-3, -1);
8888
// This selects languages[-3] to the element before languages[-1]
89-
// returns ["Python", "C"] which is the same as above
89+
// returns ["Python", "C"] which is the same as above
90+
91+
// To get an array copy
92+
const arrayCopy = [...languages]
93+
// This ... copuy the array by value
94+
console.log(arrayCopy);
95+
96+
// Get a reverse copy of array
97+
const reverseArray = languages.reverse();
98+
console.log(reverseArray);

0 commit comments

Comments
 (0)