What will be output in console:
var animals = ['Tiger', 'Lion', 'Camel', 'Cow', 'Duck']; console.log(animals.slice(2, 4));
What will be output in console:
var animals = ['Tiger', 'Lion', 'Camel', 'Cow', 'Duck']; console.log(animals.slice(2, 4));
var animals = ['Tiger', 'Lion', 'Camel', 'Cow', 'Duck']; console.log(animals.slice(2, 4));
Output in console will be Array ["Camel", "Cow"]
. The slice()
method returns a shallow copy of a portion of an array into a new array object selected from specified position to the end (excluding the end position) of array.