Difference between undefined and null in Javascript

Dec 12, 2017 00:00 · 54 words · 1 minute read

  • In Javascript undefined means a variable that has been declared but doesn’t have a value assigned, example:
var myVar; // gives undefined
typeof myVar; // gives undefined
  • null is a primitive assigned value. it can be null, empty or non-existent value, example:
var myVar = null; // gives null
typeof myVar; // gives object