Answers for "javascript get last index"

105

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
29

javascript last index

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

javascipt get last element of array

const arr = [1,2,3] ;
console.log(arr[arr.length - 1]);
Posted by: Guest on June-18-2020
2

js last index of

const str = "Users/Edit/12345";
let idx = str.lastIndexOf("/"); // returns 10
idx = str.lastIndexOf("x"); // returns -1

idx = str.lastIndexOf("Edit") // returns 6
idx = str.lastIndexOf("edit") // returns -1 -- case sensitive

// add "from" parameter
// the search happens backwards, starting at the provided from parameter
idx = str.lastIndexOf("s"); // returns 4
idx = str.lastIndexOf("s", 3); // returns 1
Posted by: Guest on August-31-2020
1

javascript array last element

var linkElement = document.getElementById("BackButton");
var loc_array = document.location.href.split('/');
var newT = document.createTextNode(unescape(capWords(loc_array[loc_array.length-2]))); 
linkElement.appendChild(newT);
Posted by: Guest on February-03-2021
0

last index of array js

array.lastIndexOf(searchElement[, fromIndex]);
Posted by: Guest on April-30-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language