About 21,800,000 results
Open links in new tab
  1. javascript - Get the last item in an array - Stack Overflow

    Array.prototype.slice with -1 can be used to create a new Array containing only the last item of the original Array, you can then use Destructuring Assignment to create a variable using the first …

  2. JavaScript Array lastIndexOf() Method - W3Schools

    The lastIndexOf() method returns the last index (position) of a specified value. The lastIndexOf() method returns -1 if the value is not found. The lastIndexOf() starts at a specified index and …

  3. c# - Finding the last index of an array - Stack Overflow

    Jun 29, 2009 · You can use this index to get last array value in any length of array. For example: var firstArray = new[] {0, 1, 1, 2, 2}; var secondArray = new[] {3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5}; …

  4. Array.prototype.lastIndexOf() - JavaScript | MDN - MDN Web Docs

    Mar 26, 2025 · The lastIndexOf() method of Array instances returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, …

  5. Find last index of element inside array by certain condition

    Dec 2, 2016 · What would be the cleanest way to get the last index of an element where a has the value 'something' - in this case index 3? Is there any way to avoid loops?

  6. Array.prototype.findLast() - JavaScript | MDN - MDN Web Docs

    May 23, 2025 · the index of the last matching element in the array, use findLastIndex(). the index of a value , use indexOf() . (It's similar to findIndex() , but checks each element for equality …

  7. How to Get the Last Item in an Array in JavaScript

    Jan 17, 2022 · When you’re programming in JavaScript, you might need to get the last item in an array. In this tutorial, we’ll go over two different ways to do this. Use index positioning if you …

  8. How to Get Last Element in Array in Java? - GeeksforGeeks

    Dec 24, 2024 · In Java, to get the last element in an array, we can access the element at the index array.length - 1 using array indexing. The length property of the array provides its total …

  9. How to Get the Last Element of an Array in JavaScript

    Dec 17, 2024 · There are several ways to get the last element of a JavaScript array, including length property and square bracket notation, slice () method and pop () method. Here are nine …

  10. JavaScript Array lastIndexOf() Method - JavaScript Tutorial

    Use the JavaScript Array lastIndexOf () method to return the last index of a matching element in an array or -1 if there is no matching found.

Refresh