What's the difference between undefined and null in javascript

Not a lot. The following statement is true:

undefined == null

So, there's no need to write:

if ( firstVar === undefined || firstVar === null)
{
  // your code
}

This works just the same:

firstVar === undefined || firstVar === null)

No comments:

Post a Comment