Let's say I have an object:
{ foo: 1, bar: 'a', baz: [1,2,3] }
How to assign a value bazto get the head and tail of an array?
I mean, the effect is the same as in the code below, except that I do not want to use an additional variable baz:
{ baz } = obj;
[head, ...tail] = baz;
I know what I can say [head, ...tail] = obj.baz, but my question is about the syntax.
source
share