Search code examples
javascriptlodash

Why does isNil method in Lodash use null instead of undefined?


Why does isNil method in Lodash use null instead of undefined?

function isNil(value) {
  return value == null;
}

Solution

  • It makes no difference either way in terms of the logic using null or undefined as null == undefined == true, but using null instead of undefined would make the file size smaller by 5 bytes.

    It's simply done to save a few bytes making the file smaller and faster to download from the server.