What is the output of 'b' + 'a' + + 'a' + 'a'?
This evaluates to "baNaNa". The trick is the lone + before 'a'.
+ "a" — the unary plus tries to convert "a" to a number, producing NaN.
Concatenation — "b" + "a" + NaN + "a" joins as strings → "baNaNa".
Lesson: a unary + coerces to a number, and NaN becomes the string "NaN" when concatenated.
console.log('b' + 'a' + + 'a' + 'a');
// Step by step:
// 'b' + 'a' = 'ba'
// + 'a' = NaN (unary + converts 'a' to number)
// 'ba' + NaN = 'baNaN' (NaN coerced to string)
// 'baNaN' + 'a' = 'baNaNa'
// More unary + examples
console.log(+ 'hello'); // NaN
console.log(+ '42'); // 42
console.log(+ ''); // 0
console.log(+ true); // 1
console.log(+ null); // 0
console.log(+ undefined); // NaNThe trick: + + 'a' has two operators. The first + is string concatenation. The second + is unary plus (type conversion to number). +'a' = NaN because 'a' is not a number.
NaN is converted to the string 'NaN' when concatenated. Result: 'baNaNa'.
Walk through step by step. The key: + + 'a' is TWO operators — string concat (+) and unary plus (+). +'a' = NaN.
NaN becomes 'NaN' when concatenated with a string. This produces the humorous 'baNaNa'.