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
1 Antwort
+ 2
And your question is?