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. :)
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
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. :)
Absolutely! And that's definitely something I could have/should have mentioned.