What will the console.log([1, 2, 3] + [4, 5, 6]) statement output?

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.

Reference:

JavaScript MCQ (Multiple-Choice Questions)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top