Answers for "js copy part of array"

1

js copy part of array

// The slice function copies parts of an array and 
// do therefore not change the default array

let arr = ["apple", "kiwi", "banana", "pear"];

let newArray = arr.slice(1, 2)

console.log(newArray); // output : kiwi
Posted by: Guest on September-10-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language