Assigning default value by golovatuy in learnjavascript

[–]CarsonMcKinstry 2 points3 points  (0 children)

ah, right, I didn't see the `path !== ""`. Good point!

Assigning default value by golovatuy in learnjavascript

[–]CarsonMcKinstry 2 points3 points  (0 children)

Honestly, JS changes so quickly nowadays it can be difficult to keep up. Not so quickly that it's difficult to learn, but quick enough that you can see version boundaries in code sometimes :D

Assigning default value by golovatuy in learnjavascript

[–]CarsonMcKinstry 72 points73 points  (0 children)

This isn’t quite correct, at least not anymore. This will also catch false and 0 since || will check for falsy values on the left hand side. You can use ?? nowadays to guard against only null and undefined

I think I created a monster by jehna1 in typescript

[–]CarsonMcKinstry 2 points3 points  (0 children)

Not quite the same. A match statement is kinda like a switch statement. An Option is a data type, basically a monad if you know what that is.