Closed dannyfritz closed 10 years ago
I've always had a problem with the default values trick using ||. What if you want to default the used value to 0?
||
used
https://github.com/bevacqua/js/tree/3aa78500a96e4ca5cf13867593081da07b83f31c#everyday-tricks
Use used || 0, then
used || 0
If you want to allow falsy values then you need a ternary expression
value === void 0 ? defaultValue : value
I've always had a problem with the default values trick using
||
. What if you want to default theused
value to 0?https://github.com/bevacqua/js/tree/3aa78500a96e4ca5cf13867593081da07b83f31c#everyday-tricks