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

Programmer Humor

37575 readers
810 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
[โ€“] dan@upvote.au 7 points 2 years ago* (last edited 2 years ago) (1 children)

response indicating that there was no value assigned in the first place.

You can explicitly assign undefined to a variable though.

Another fun fact about JavaScript is that undefined never used to be a keyword. If you did var foo = undefined, foo would indeed have a value of undefined, but it was only because there was no variable called undefined in scope!

You could do var undefined = 42 then var foo = undefined would actually set foo to 42! window.undefined = 42 would break all sorts of things.

Thankfully this was fixed with ES5 in 2009, although it took a few years for browsers to make the change.

[โ€“] darcy@sh.itjust.works 4 points 2 years ago

javascript moment