A

Admin • 833K Points
Coach

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

Code:
// JavaScript Equalto Operators
function equalto()
{
let num=10;
if(num==="10")
return true;
else
return false;
}
  • (A) false
  • (B) true
  • (C) compilation error
  • (D) runtime error
  • Correct Answer - Option(A)
  • Views: 20
  • Filed under category JavaScript
  • Hashtags:

Explanation by: Admin

A === operator in JS is only true if the operands are of the same type and the contents match. Two strings are strictly equal when they have the same sequence of characters, same length, and same characters in corresponding positions. In this case, we are comparing an integer and a string so it will be false.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.