Logo

Programming-Idioms

History of Idiom 165 > diff from v43 to v44

Edit summary for version 44 by justafoo:
[JS] const

Version 43

2019-09-26, 15:11:43

Version 44

2019-09-26, 18:27:01

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];
Code
const x = items[items.length - 1];
Origin
https://stackoverflow.com/a/9050354/871134