Created
September 2, 2022 14:34
-
-
Save Tonel/3eb279c45b03d99272773e06226a9135 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const array1 = []; | |
// adding 100k elements to array1 | |
for (let i = 0; i < 500000; i++) { | |
array1.push(i); | |
} | |
// creating a copy of the array1 variable | |
const array2 = []; | |
// adding one element at a time | |
array1.forEach((e) => { | |
array2.push(e); | |
}); | |
console.log(array2.length); // 500000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment