This site is a preview of the curriculum for our Summer 2018 bootcamp in Burlington, Vermont. As we continue our preparation, courses and lessons will appear and disappear; we will rename, rearrange, clarify, and obfuscate as needed... Please consider this a work in progress and keep checking in.

 Learn to Code with JavaScript:



null is a magic pointer

There Is No Spoon

Neo With Spoon

null is the pointer to an object that means "there is no object"


let fruit = "apple"
fruit = null

Read the error!

Errors are good

They tell you

  • you made a mistake
  • what that mistake was
  • (sometimes) how to fix it

Interpret this error:

TypeError: Cannot read property 'toUpperCase' of null

null pointer errors

  • null pointer errors are very common
  • the trick is reading the error and figuring out
    1. where it happened (*which line*)
    2. which variable was null
    3. why it was null
  • often once you know which, knowing why is obvious
    • but sometimes it's a puzzle

If You're Going To Fail...

Two philosophies:

  • fail hard, fail fast
  • keep calm and carry on

Which idea is better?

Why or why not?

JavaScript has several nulls

  • null
  • undefined
  • NaN
typeof null          // "object" (not "null" for legacy reasons)
typeof undefined     // "undefined"
null === undefined   // false
null == undefined    // true
null === null        // true
null == null         // true
!null                // true
1 + null             // 1
1 + undefined        // NaN

Docs: MDN: null


comments powered by Disqus