Get the last N elements of an Array in JavaScript

 

how to get the last n elements of an array in JavaScript.

 

const num= ["1", "3", "4", "7"];

const lastTwo = num.slice(-2);

Tags:

Share:

Related posts