What is the output of following code?
console.log( 10 + "2");
----o----
Output is "102"
.
Plus operator +
in JavaScript can be used for numeric addition or string concatenation. When one of the operands is of string type, +
does concatenation. Therefore, in this example 10
is converted to a string and the output is "102"
.