Default Values
dannyfritz opened this issue · 2 comments
dannyfritz commented
I've always had a problem with the default values trick using ||
. What if you want to default the used
value to 0?
https://github.com/bevacqua/js/tree/3aa78500a96e4ca5cf13867593081da07b83f31c#everyday-tricks
bevacqua commented
Use used || 0
, then
bevacqua commented
If you want to allow falsy values then you need a ternary expression
value === void 0 ? defaultValue : value