you are viewing a single comment's thread
view the rest of the comments
[–] 12 points 3 years ago (4 children)

not sure the distinction between null and undefined is doing anything for me here

  • source
  • hideshow 4 child comments
  • [–] 8 points 3 years ago

    Basically JavaScript uses undefined to mean keys that don't exist. You know how sometimes when you're wondering about the semantics of "present but null" and "absent"? It's basically that. Undefined means it isn't there but things are only null if they've been set to null.

    There are probably more nuances but that is the gist.

  • source
  • parent
  • [–] 3 points 3 years ago (1 child)

    Depends on the programming language. In JavaScript, it literally means that like the key or variable does not actually exist. Whereas like in C/C++, writing random bytes to random memory addresses would result in "undefined behaviour" which means basically anything could happen.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 2 points 3 years ago*

    In Javascript you can do let a = undefined, defining the variale a as undefined.

    A significant difference to defining it as null is that typeof null == "object", while typeof undefined == "undefined".

  • source
  • parent