0

Get the last item in an array (JavaScript)

1st using length method: let arr = [22, 44, 66, 60, 7]; let le = arry[arr.length - 1]; console.log(le); // output: 7 ======= 2nd using slice() method: let arr = [22, 44, 66, 60, 7]; let le= arr.slice(-1); // output: 7 ======= 3rd using pop() method: let arr = [22, 44, 66, 60, 7]; let le= arr.pop(); // output: 7 which one fast? pop() method

3rd Sep 2022, 9:06 AM
Sakib Ahmed
Sakib Ahmed - avatar
1 Resposta
+ 2
And your question is?
3rd Sep 2022, 9:14 AM
A͢J
A͢J - avatar