• gornius@lemmy.world
    link
    fedilink
    arrow-up
    7
    arrow-down
    2
    ·
    edit-2
    1 year 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
      ·
      1 year 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
      ·
      1 year ago

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