JS Coding Questions Logo
JS Coding Questions
#360💼 Interview💻 Code

What happens if we add two arrays

Advertisement

728x90

If you add two arrays together, it will convert them both to strings and concatenate them. For example, the result of adding arrays would be as below,

javascript
1console.log(["a"] + ["b"]); // "ab"
2
3console.log([] + []); // ""
4
5console.log(![] + []); // "false", because ![] returns false.

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 17

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
360of476