Answers for "how to check the last item in an array javascript"

98

javascript get last element of array

var foods = ["kiwi","apple","banana"];
var banana = foods[foods.length - 1]; // Getting last element
Posted by: Guest on June-20-2020
5

find last element in array javascript

var heroes = ["Batman", "Superman", "Hulk"];
var lastHero = heroes.pop(); // Returns last elment of the Array
// lastHero = "Hulk"
Posted by: Guest on June-11-2020
2

js array last element get

.slice(-1)[0]
Posted by: Guest on July-13-2020
0

how to check the last item in an array javascript

const colors = ['red', 'yellow', 'green', 'blue']
const lastItem = colors[colors.length - 1]
console.log(lastItem)
Posted by: Guest on February-01-2021
-1

how to find last element in array

int [] y={1,2,3,4,5};
int c=(n.length-1);
Posted by: Guest on September-21-2020

Code answers related to "how to check the last item in an array javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language