Differences between Javascript NULL and Undefined

This one is pretty slippy.

The main differences are that:

  • Undefined, as its name suggests, is the value when a variable’s value has not been defined.
  • Null is a value of “no value”.
  • Undefined can have the value of null
  • Null can not have the value of Undefined
  • The == equality operator will return true for a comparison of an undefined variable and null variable
  • The === identity operator will return false for a comparison of an undefined variable and a null variable
  • Undefined is its own type
  • Null is typeof object
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s