Nullish unary operator `?`

I just remembered this idea now when I came across something similar, so just came in to drop a hi.

I think 'non-nullish' as its name is totally fine, unless you want to coin a new term like fullish, which would be kinda foolish :face_with_hand_over_mouth:.

I would oppose the isNullish() thing cuz I don like jamming simple operations like these which need simple operators into gross utility functions. Besides, its longer than doing ?a anyway and if we wanted, we could declare it ourselves.

Also, sheepishly, this is a kinda use case for my Unions proposal which nobody liked :pleading_face:. But I would still prefer a nullish operator for this all the same.

foo !== undefined && foo !== null

foo !== null &~ undefined // TADA

I'm very positive for this idea and would love to see this in the language. I just hope it's given the attention it deserves and championed soon :)

1 Like