Logo

Programming-Idioms

History of Idiom 165 > diff from v1 to v2

Edit summary for version 2 by programming-idioms.org:
New JS implementation by user [programming-idioms.org]

Version 1

2017-10-21, 18:45:08

Version 2

2017-10-21, 20:01:02

Idiom #165 Last element of list

Assign to variable x the last element of list items.

Idiom #165 Last element of list

Assign to variable x the last element of list items.

Code
var x = items[items.length - 1];
Origin
https://stackoverflow.com/a/9050354/871134