Timeline for answer to Get the last item in an array by Mohoch
Current License: CC BY-SA 3.0
Post Revisions
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 8, 2017 at 2:54 | comment | added | Bruno Peres |
If performance is an issue, know that this method is a lot slower than array[array.length - 1] jsperf.com/get-last-item-from-array/13
|
|
| Mar 31, 2016 at 8:26 | history | edited | Mohoch | CC BY-SA 3.0 |
added 4 characters in body
|
| May 22, 2013 at 6:57 | history | edited | Mohoch | CC BY-SA 3.0 |
Corrected the code by @Cees Timmerman 's comment
|
| May 21, 2013 at 10:31 | comment | added | Cees Timmerman |
Slice returns an array, though, so use arr.slice(-1)[0], like this answer.
|
|
| Feb 12, 2013 at 9:13 | history | answered | Mohoch | CC BY-SA 3.0 |