Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js get last n elements of array

const cars = ["benz", "bmw", "volvo", "skoda"];

const lastThree = cars.slice(-3);

console.log(lastThree); // ["bmw", "volvo", "skoda"]
Source by reactgo.com #
 
PREVIOUS NEXT
Tagged: #js #elements #array
ADD COMMENT
Topic
Name
6+1 =