Single Choice Not Set

QWhat is the result of the following code?

let x = 10;
let y = '10';
console.log(x == y);

ID: #4856 Basic JavaScript MCQ 214 views
Question Info
#4856Q ID
Not SetDifficulty
Basic JavaScript MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A true
  • B false
  • C 10
  • D '10'
Correct Answer

Explanation

The result of the code is true.
The == operator in JavaScript performs type coercion, which means that it converts the operands to the same type before performing the comparison.
In this case, the string '10' is converted to the number 10, so the comparison returns true.

Share This Question

Challenge a friend or share with your study group.