This const [, last] = someArray is equal to const last = someArray[1] To use destructuring, one might want something like const [l, [l - 1]: last] = someArray, but it's hardly more readable 😁
const [, last] = someArray
const last = someArray[1]
const [l, [l - 1]: last] = someArray
@milichev I get the idea from your snippet but I think the syntax is incorrect, it should look something like this :
const { length, [length - 1]: last } = [1, 2, 3, 4]; // last === 4
Anyways that's a funny thing I never thought of :)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This
const [, last] = someArray
is equal toconst last = someArray[1]
To use destructuring, one might want something like
const [l, [l - 1]: last] = someArray
, but it's hardly more readable 😁@milichev I get the idea from your snippet but I think the syntax is incorrect, it should look something like this :
Anyways that's a funny thing I never thought of :)