Languages are constantly changing. And if you've read other posts of mine you know that I love checking in on the latest and greatest in JavaScript...
For further actions, you may consider blocking this person and/or reporting abuse
This combined with optional chaining is about to remove 75% of the reason I use lodash and I love it.
Great examples for how valuable the
??
operator is! I think what makes it even better is that we can still use||
in the few cases when we want to treat""
and0
as false. In codebases where this becomes common practice, it will be easy to tell at a glance what values can be expected for the initial variable.Absolutely. Addition not replacement is key!
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.
This is rad. Nullish coalescing will be very useful. I’m looking forward to your write up on optional chaining.