Returns the last element of an array.
null if the array was empty.Array[Array.length-1], or Array.at[-1]. Its main purpose is to provide an alternative syntax, which may – at least in some circumstances – result in more readable code.A simple example could look like this:
let foo = document.getElementsByTagName('foo'); let bar = foo.last(); if (bar) { … }