Answers for "copy an array slice"

1

Clone an array using the JavaScript slice() method

var numbers = [1, 2, 3, 4, 5];
var clonedNumbers = numbers.slice();
console.log("Cloned Numbers are:", clonedNumbers)
Posted by: Guest on November-29-2021
1

JavaScript Array slice() example

let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let newArray = numbers.slice(4,8);
console.log("The sliced arrays is:", newArray)

// Output: The sliced arrays is: [ 5, 6, 7, 8 ]
Posted by: Guest on November-29-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language