Why does this JavaScript statement:
console.log(1 + + \"2\");
print
3
as the output? I am not sure why
console.log(1 + "2") prints 12 as + acts as an concatenation operator.
console.log(1 + "2")
+
But if you try to print console.log( + "2" ) you will get output as 2 coz it is casted as an integer.
console.log( + "2" )
Therefore console.log( 1 + +"2" ) will give you result as 3
console.log( 1 + +"2" )