Answers for "how to change one array value to the last index in javascript"

34

last index array javascript

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

replace last element of array javascript

var array = [10,11,12,13,14,15,16,17];
array.splice(-1,1);
console.log(array);
Posted by: Guest on January-03-2022

Code answers related to "how to change one array value to the last index in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language