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 trialstephen miller
5,907 Pointsquick 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
8,947 PointsThe 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
12,081 PointsGenerally 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
8,746 PointsI heard it is better to use three equal sign every time you work in JS.