Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

last element in javascript

const arr = [1,2,3,4];
const last = arr[arr.length - 1];
console.log(last); // 4

const arr = [1,2,3,4];
const last = arr.at(-1);
console.log(last); // 4

const arr = [1,2,3,4];
const last = arr.findLast(x => true);
console.log(last); // 4
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #element #javascript
ADD COMMENT
Topic
Name
7+4 =