What is the result of the following code snippet? console.log(1 + ‘2’);

Web Development Easy

Web Development — Easy

What is the result of the following code snippet? console.log(1 + ‘2’);

Key points

  • The '+' operator triggers string concatenation if one operand is a string.
  • JavaScript automatically coerces types to perform operations.
  • Numeric addition only occurs if both operands are numbers.

Ready to go further?

Related questions