Difference between Null and Undefined ( JS )

Mostafa Kamal
code4mk organization
2 min readApr 27, 2018

--

Null vs Undefined // code4mk //

Null and Undefined both are falsy value in JavaScript .

# Null

  • object ( typeof)
  • empty
  • not exist
  • must be defined
let name = 'kamal';
console.log(name.match('jamal'));
// output: null

# Undefined

  • declare variable but value not define
  • undefined ( typeof)
let name;
console.log(name);
// output: undefined
null == undefined
// output : true [ equality rules]

.

null === undefined
// output : false [identity rules]

# Resources

--

--