Answers for "how to get the last li of ul in js"

1

last element from list javascript

const lastItem = colors[colors.length - 1]
Posted by: Guest on June-19-2020
0

javascript last in a list

let list = ["item1", "item2", "item3", "etc"];
let last = list.reverse()[0]
// or
let last = list[list.length - 1]
// or
let last = list.slice(-1)
Posted by: Guest on February-20-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language