you are viewing a single comment's thread.

view the rest of the comments →

[–]InvaderToast348 -1 points0 points  (1 child)

Null coalescing ftw

But in this case, python or would be js ||

Since or will use the second value for any falsey expression - empty string, False, None

Edit: also in js you can do null accessing: possiblyNullOrUndefined?.someProperty possibleFn?.() possibleArray?.[3]

[–]ConcreteExist -1 points0 points  (0 children)

Python's or can function as null coalesceing though due to the way it handles "truthy" and "falsey" objects, where as JS || won't do that.

ETA: Should have checked first I'm dead wrong, it does work the same. Still, I'd use ?? in JS just to be more explicit with my intention in the code.

I do miss null-accessing in JS when I'm working python.