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

hakan Gülay
hakan Gülay
8,489 Points

couldnt solve

http://teamtreehouse.com/library/null-and-undefined-2

ı really couldnt solve this question actually ı couldnt understand can you plase tell me answer ? then ı can learn something from answer

2 Answers

J Scott Erickson
J Scott Erickson
11,883 Points

Think of it this way, both null and undefined are falsey values. Which when being compared using == appear to be the same ( in javascript ).

However, using the === comparison goes deeper, and not only compares the two as falsey values, but checks to see if they are of the same type. If they are not, then it will evaluate false. And would go down the other control direction in the if clause, of skip if there is no other place to go.

J Scott Erickson
J Scott Erickson
11,883 Points

*compares not campsites, iphone spelling error :-p

James Barnett
James Barnett
39,199 Points

Think of it this way, both null and undefined are falsey values. Which when being compared using == appear to be the same ( in javascript ).

The technical term for JavaScript "considering 2 values to the same" is called type coercion

hakan Gülay
hakan Gülay
8,489 Points

it was too easy . how ı couldnt get it :)) thank you so much ı need to practise more ^^

J Scott Erickson
J Scott Erickson
11,883 Points

Its all in the practice ;-) === is a javascript and php ( there are likely more languages that I can't think of ) quirk.