K K K K - 8 days ago 5
Javascript Question

How == works in case of 10 =="10" in JavaScript?

When we compare 10 == "10". JavaScript gives output as true. Does that mean first operand 10 (

Number
) gets converted to "10" (
String
) or vice-versa?

Answer

Using the table in this document 10 == "10" means that the code behaves as A === ToNumber(B) i.e. the string gets converted to a number

Comments