Question · JavaScript and TypeScript course · Module 2: Functions, Arrays and Objects

null vs undefined

What is the difference between null and undefined in JavaScript?

Answer options

  • null is an error, undefined is a valid value
  • null means an intentional absence of value, undefined means that a variable has not been assigned a value yet
  • undefined means an intentional absence of value, null means that a variable has not been assigned a value yet
  • They are identical values
Show the answer

Correct answer:

  • null means an intentional absence of value, undefined means that a variable has not been assigned a value yet