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 Basics (Retired) Making Decisions with Conditional Statements Introducing Conditional Statements

Lea Coetzee
Lea Coetzee
3,035 Points

What is the benefit of === as opposed to == in this scenario?

=== vs == in this scenario - is there a benefit and why does the teacher use === here?

2 Answers

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

the == is the equal to operator, the === is the identical to (equal and also of same type) operator. the equal == attempts to convert the type of one operand to the same type as the other, whereas the identical === does not type convert. this means that 5 == '5' will return true, but 5 === '5' will return false.

Lea Coetzee
Lea Coetzee
3,035 Points

Hi James,

thanks for the reply.

Indeed, I understand it now too. If anybody else was also wondering, he actually explains this in the very next video.