Why does this JavaScript statement:
console.log(1 + + \"2\");
3
as the output? I am not sure why
Regarding the specific output of
console.log(1 + + "2");
Run it on your browser console. The better question is why does it output what it does -
console.log(1 + + "2");
^
That is the binary +
operator, which will concatenate strings or add numbers.
console.log(1 + + "2");
^
That one is the unary +
operator, which converts "2" to a number.
Don't create JavaScript like this. It's confusing.