• gornius@lemmy.world
    link
    fedilink
    arrow-up
    7
    arrow-down
    2
    ·
    edit-2
    11 months ago

    The way I use it is ‘undefined’ is literally undefined (not set), but null means no value - explicitly.

    • FiniteLooper@lemm.ee
      link
      fedilink
      English
      arrow-up
      5
      ·
      11 months ago

      I used to ban null usages with ESLint rules for this exact reason. If it’s there use a value, if not use undefined

    • chaorace@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 months ago

      Except you can define a value with undefined and accessing that value will have different behavior than attempting to access an undefined value.