this post was submitted on 05 Oct 2023
1097 points (96.8% liked)

Programmer Humor

37322 readers
177 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] gornius@lemmy.world 5 points 2 years ago* (last edited 2 years ago) (2 children)

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

[–] FiniteLooper@lemm.ee 5 points 2 years 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 1 points 2 years ago

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