Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Website Optimization Chrome DevTools Basics The Console Panel

stephen miller
stephen miller
5,907 Points

quick question about operators

I took another course on js and jquery and the teacher explained that when using the 'equals operator' unlike Java, you use 3 equals signs === instead of 2. However in the console you were only using 2 and it was working fine, am i missing something? :0 thanks!

3 Answers

Niclas Valentiner
Niclas Valentiner
8,947 Points

The difference between == and === is that === also compares the variable type.

var a = 1
var b = '1'


a == b  //returns true
a === b // returns false, one is a string and the other is an integer
Jeremy Castanza
Jeremy Castanza
12,081 Points

Generally speaking, you're better off using three equal signs. It'll get you into less trouble and will help you to debug your programs more easily.

Eddy Yi
Eddy Yi
8,746 Points

I heard it is better to use three equal sign every time you work in JS.