-2

I can not understand what is the main difference between null and undefined.

  • 3
    [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) – Andreas Aug 31 '21 at 06:20
  • `console.log(a)` : `a` is undefined. It doesn't exist at all. `typeof a === "undefined"`. But if you do `const a = null`, then `a` is defined. Its value is a null object, but it is defined and exists. `typeof a === "object"`. – Jeremy Thille Aug 31 '21 at 12:46

1 Answers1

1

Null: It is the intentional absence of the value. It is one of the primitive values of JavaScript.

Undefined: It means the value does not exist in the compiler. It is a global object.

Dmytro
  • 636
  • 1
  • 3
  • 18