What will the console.log([1, 2, 3] + [4, 5, 6]) statement output?
a)
"1,2,34,5,6"
b)
"1,2,3,4,5,6"
c)
[1,2,3,4,5,6]
d)
NaN
Answer:
a)
"1,2,34,5,6"
Explanation:
In JavaScript, when you use the +
operator with arrays, it converts the arrays to strings and concatenates them. Therefore, the result is "1,2,34,5,6"
, a concatenated string of the two arrays.