JavaScript is a dynamic language and it does automatic data type conversions if required by operations.
Let's take all cases of data type conversions with the addition operator (+) into consideration.
Just like any other programming language '+' is used for adding numeric data or concatenating strings. In this case there are no automatic conversions:
console.log(40 + 2); // 42
console.log("40" + "2"); // "402"
If one operand is a string the other operand is converted to string:
console.log("40" + 2); // "402"
console.log("40" + false); // "40false"
console.log("40" + []); // "40"
In cases where none of the two operands is a string and both operands are primitive (number, boolean, null, undefined), both operands are converted to numbers and added:
console.log(false + 3); // 3
console.log(false + true); // 1
console.log(null + true); // 1
console.log(null + null); // 0
If one operand is an object both operands are converted to strings and concatenated:
console.log([2] + 40); // "240"
Also, keep in mind that '+' operator has left-to-right associativity. You can read more about operator associativity here.
Considering all the above cases of '+' operator, and answer which one of the followings will log 'true':