Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

love u trolls

too old

2 Answers

Chris Shaw
Chris Shaw
26,650 Points

The triple equals ensures that the values and types of both the left and right side of the comparison match each other, for example the following will result in true when the alert is executed as the int type of 2 gets modified to a string which can be compared as a success.

alert(2 == '2'); // true

When using the strict comparison both the left and right values must equal the same value and type so the following wouldn't work as an int of 2 is not the same as the string 2.

alert(2 === '2'); // false

Personally I don't recommend w3schools as they are out-of-date and don't have accurate information, the Firefox dev team and the community do an awesome job by keeping the Mozilla Developer Network up-to-date.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Comparison_operators

thank you I really need to use mozilla often sometimes

Jeremy Frimond
Jeremy Frimond
14,470 Points

joe santos garcia trying give a look at this section on W3schools. there is some explanation along with examples that may give you a good idea of how they differ and more importantly when to use them. http://www.w3schools.com/js/js_comparisons.asp

If this doesnt help let me know and I will try to see if I can explain it another way that may help