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 Variables Null and Undefined

Lisel Jensen
Lisel Jensen
874 Points

Is this exercise wrong??

Undefined == NULL evaluates to TRUE undefined === NULL evaluates to FALSE and would not execute the "if" statement.

3 Answers

Kevin Murphy
Kevin Murphy
24,380 Points

Undefined and Null are not specifically equivalent hence undefined === NULL evaluates to False. The number of equal signs chosen for the operator makes a big difference in this case. Jim explains this quirk of JS in the video so make sure you note that section. Circle back if still having trouble.

The exercise is not wrong. It's teaching you the difference between the equality operator (==) and the identity (===) operator.

The equality operator enables type coercion, converting values of different types into same type so that they can be compared.

The identity operator does not enable the type coercion, so it only returns true for same values which are also of same type.

Lisel Jensen
Lisel Jensen
874 Points

Oh, I see. I misread the question. Thanks