1var colors = ["red","blue","green"];
2var green = colors[colors.length - 1];//get last item in the array
1//====================================
2//find last element in array javascript
3var heroes = ["Batman", "Superman", "Hulk"];
4var lastHero = heroes.pop(); // Returns last elment of the Array
5// lastHero = "Hulk"
6
7//========================================
8//get last item in array
9let array = [1,2,3,4,5]
10let sliced = array.slice(-1)[0]
11
12//OR
13let popped = array.slice(-1).pop()
14
15//OR
16let lengthed = array[array.length - 1]
17
18
19
20//==========================================
21//javascript last element of array
22var last = arr.slice(-1)[0]
23
24//==========================================
25// last element of array
26let arr = [1,2,3]
27arr[arr.length - 1] //returns last element in an array
28
29//==========================================
30//get last element of array javascript
31var numbers = ["one", "two", "three"];
32var lastnumber = numbers[numbers.length - 1];
33console.log(lastnumber);
34
35
36//==========================================
37// get last element of array
38
39const arr = [1,2,3] ;
40console.log(arr[arr.length - 1]);
41
42//===========================================
43// last element of array
44arr.slice(-1)[0]
45
46//========================================
47// get last item in array
48var colors = ["red","blue","green"];
49var green = colors[colors.length - 1]; //get last item in the array
50
51//=========================================
52// get last element of array
53var name = ["jon","tem","kevin", "ramos"];
54var lastNameInArray = name[name.length - 1];// >> ramos
55
56
57//==========================================
58//get last element of array
59var foods = ["kiwi","apple","banana"];
60var banana = foods[foods.length - 1]; // Getting last element
61
62//======================================
63//get last element in array
64var my_array = /* some array here */;
65var last_element = my_array[my_array.length - 1];
66
67
68
69
70
71
72
73
1var my_array = /* some array here */;
2var last_element = my_array[my_array.length - 1];
3