Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //cara 1
- let array1 = [1,2,3];
- let array2 = [].concat(array1);
- console.log(array2); //[ 1, 2, 3 ]
- array2.push(4,5,6);
- console.log(array2); //[ 1, 2, 3, 4, 5, 6 ]
- console.log(array1); //[ 1, 2, 3]
- //cara 2
- let array3 = [1,2,3];
- let array4 = [...array3];
- console.log(array4); //[ 1, 2, 3 ]
- array4.push(4,5,6);
- console.log(array4); //[ 1, 2, 3, 4, 5, 6 ]
- console.log(array3); //[ 1, 2, 3
Advertisement
Add Comment
Please, Sign In to add comment