What is the difference between == and === in JavaScript?

Asked by
?
Curious Learner
1mo ago 0 views
1 answer
Best Answer
== compares with type coercion; === compares value AND type.

Examples:
5 == "5" → true (string converted to number)
5 === "5" → false (different types)

Best practice: Always use === for predictable results.

Your Answer

Be specific and provide details to help the person asking.