Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

slice array jas

// array.slice(start, end)
const FRUITS = ["Banana", "Orange", "Lemon", "Apple", "Mango"];
var citrus = FRUITS.slice(1, 3);
// citrus => [ 'Orange', 'Lemon' ]


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 ]
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #slice #array #jas
ADD COMMENT
Topic
Name
8+5 =