3 ms·
I don't know, if you'd never done any Python, and perhaps particularly if you learnt JS in 'callback hell' days, you might not realise what was wrong with:
by OJFord 5y ago
I don't know, if you'd never done any Python, and perhaps particularly if you learnt JS in 'callback hell' days, you might not realise what was wrong with:
def doSomething(theArgs, cb):
food, bard = 0, 0
try:
doFoo(theArgs["foo"], lambda: food = 1)
doBar(theArgs["bar"], lambda: bard = 1)
except Exception:
cb(food + bard, "didn't work")
else:
cb(food + bard, None)
or whatever.
I can get by in JS, I use it professionally even now, but it's not good quality; I know that. (Trivial example, I discovered `??` recently. I've definitely written a lot of null/undefined checks without it, or even naive ternaries that assume non-null/undef values aren't falsey (`thing ? thing : 123` vs. `thing ?? 123`) - which is kind of like seeing `dict.get(key, None)` in python.)