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
πŸ’¬ Discuss
βœ… Correct Answer: (A) false
Explanation: 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.
Explanation by: Chandani
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.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
151
Total Visits
πŸ“½οΈ
2 y ago
Published
πŸŽ–οΈ
Chandani
Publisher
πŸ“ˆ
80%
Success Rate