Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on What's the difference between =, == and === operators in JavaScript?
Parent
What's the difference between =, == and === operators in JavaScript?
While learning JavaScript, I started to see =, == and === operators. What's the difference between them?
Post
The following users marked this post as Works for me:
| User | Comment | Date |
|---|---|---|
| will.octagon.gibson | (no comment) | May 4, 2026 at 16:25 |
These are the differences between these operators:
The Assignment Operator (=)
This isn't for comparing things; it’s for giving a value to a variable. It’s like putting a label on a box.
-
Example:
let fruit = "Apple"; -
Translation: "Take the box named 'fruit' and put an 'Apple' inside it."
The Loose Equality Operator (==)
This checks if two things are roughly the same value. It’s like a friendly clerk who doesn't care if you pay with a 5 dollar bill or five 1 dollar coins, they both "equal" five dollars.
-
Example: 5 == "5" (True)
-
Translation: "Is the number 5 close enough to the word '5'?" JavaScript says yes because it converts the word into a number for you.
The Strict Equality Operator (===)
This is the "perfectionist." It checks that the value AND the type (like number vs. text) are exactly the same.
-
Example: 5 === "5" (False)
-
Translation: "Is the number 5 exactly the same as the word '5'?" JavaScript says no—one is a number, and the other is just text that looks like a number.
Almost all developers use === by default. It’s safer because it prevents JavaScript from making "helpful" guesses that might lead to weird bugs later on.

0 comment threads