nullundefinedThe difference between

1.Null

  • nullRepresents a “none” object, converted to a value of0;
  • As arguments to a function, indicating that the function’s arguments are not objects;
  • As the end of the object prototype chain;
  • Number(null)0;
  • 5 + null5;
  • JSON.stringify(null)'null'(string);
  • JSON.parse(null)null (nullBasic type).

2,Undefined

  • The variable is declared, but not assigned, is equal toundefined;
  • When the function was called, the argument that should have been provided was not providedundefined;
  • The object has no assignment property, which has a value ofundefined;
  • The function returns no value by defaultundefined;
  • Number(undefined)NaN;
  • 5 + undefinedNaN;
  • JSON.stringify(undefined)undefined;
  • JSON.parse(undefined)Error == for ==.