Answers for "accessing the last index in an array js"

34

Javascript get last item in array

var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array
Posted by: Guest on July-25-2019
1

get the last element of array javascript

let array = [1, 2, 3, 4, 5]
array.at(-1) // last element on array (5)
Posted by: Guest on December-01-2021

Code answers related to "accessing the last index in an array js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language