A

Admin • 833K Points
Coach

Q. What will be the output of the following code?

Code:
console.log(2 + '2');
  • (A) 4
  • (B) 22
  • (C) NaN
  • (D) Error
  • Correct Answer - Option(B)
  • Views: 25
  • Filed under category JavaScript
  • Hashtags:

Explanation by: Admin

JavaScript coerces the number 2 to a string and concatenates, resulting in '22'.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.