Message from JavaScript discussions

October 2020

— Thanks!

— 

've seen some

if compound.item
# item exists
if compound.item.variant
# variant defined
# ...

to

if (a = compound.item) and a.variant
# item and variant exists
# ...

— If there are 2 places, it sux.. should go one way down

— Problem is that compound.item can be null, and it's valid

— Or false

— Only when there is no key variant then result is compound.item

— This is when you need TypeScript

— How can TypeScript help here? haha (equally I am already using it (:

— It makes me sad to see how the uninitiated are groveling in the dirt

— Well it tells you if .item can be null or not ofc

— The point is that I don't want to be using Object.keys to check for the key.. I want something less hacky, I like challenges

Message permanent page

— 'key' in obj