You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2024. It is now read-only.
With ES2015 array destructuring, I find that let [lastItem] = arr.slice(-1) is a nice way to access the last item. It is hard to make a mistake with this syntax, which I think defeats all the reasons given in the rationale section of the README. It also has the benefit of not referencing arr twice, which means you can use it as let [lastItem] = someComplexExpressionToComputeArr().slice(-1). Without destructuring, you can still use arr.slice(-1)[0], which is only 4 characters longer than arr.lastItem.