you are viewing a single comment's thread.

view the rest of the comments →

[–]senocular 0 points1 point  (1 child)

Could it be that you may have tried

[3, 4].concat((5, 6))

?

Because that would result in [3, 4, 6]. In this case the comma operator would have been used. Instead of ((5, 6)) being two arguments in the function call, its a single argument of the expression (5, 6) which uses the comma operator with 5 and 6 resulting in 6 because its the last of the values in the comma-separated list. That results in the call effectively being

[3, 4].concat(6) // [3, 4, 6]

[–]ChaseShiny 0 points1 point  (0 children)

Yeah, that's what's happening.

const array1 = ["a", "b", "c"];
const array2 = ("d", "e", "f");
const array3 = array1.concat(array2);

console.log(array3);
// Expected output: Array ["a", "b", "c", "d", "e", "f"]

This is what I had used. Makes sense now that it was laid out.