In JavaScript it's possible to merge array with another using the ...
(spread) operator as follows
[...[1,2,3], ...[4,5,6]]
// -> [1, 2, 3, 4, 5, 6]
However, it seems ineligible to use the spread operator inside ternary ?
expression
[true ? ...[1,2,3] : ...[4,5,6]]
// Uncaught SyntaxError: Unexpected token ...
Is this a justified restriction in the language, a deficiency or am I missing something? Is is possible to achieve this syntactically without imperative approach or Object.assign()
function?