Default Values
dannyfritz opened this issue · comments
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
Use used || 0
, then
If you want to allow falsy values then you need a ternary expression
value === void 0 ? defaultValue : value