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

JavaScript JavaScript Foundations Numbers Comparisons

John Grillo
John Grillo
30,241 Points

Fine point differences between '==' and '===' ?

I just want to learn the greater differences and fine points--and pitfalls--of the '==' and '==='. I'm not sure I understood all the salient points of the video, even with the transcript.

1 Answer

William Li
PLUS
William Li
Courses Plus Student 26,868 Points
"6" == 6  // true
"6" === 6  // false

0 == false  //true
0 === false //false

You see here, === is stricter comparison because it requires the two objects being compared to are of the same type, whereas == allows type conversion before comparing.

In his iconic JavaScript book, JavaScript: The Good Parts, Douglas Crockford argues that you should always use === and forget about ==, and you should probably listen to him.