DEV Community

Discussion on: Nullish Coalescing - Let Falsy Fool You No More

Collapse
 
aaron_powell profile image
Aaron Powell

Love this! I transformed our codebase at work with this along with Optional Chaining and it's so much more eloquent.

I also changed array.length > 0 checks for array?.[0] checks when we knew what the array was dealing with.

I do think it's worth mentioning that not all || situations will you want to convert to ?? as there are some very valid scenarios where treating falsy values as false is needed. :)

Collapse
 
laurieontech profile image
Laurie

Absolutely! And that's definitely something I could have/should have mentioned.