Regarding your updated code:
const limit = !options.limit || options.limit === NaN ? 0 : options.limit
- If
options.limit
isfalsy
, this will setlimit = 0
. Else, it will useoptions.limit
- The second condition is not required because
NaN
is a falsy value. It is already covered in!options.limit
condition. - Also,
options.limit === NaN
is never true, not even ifoptions.limit
isNaN
. You need to useisNaN()
orNumber.isNaN()
to check forNaN
Your current code is equivalent to:
const limit = options.limit || 0.
3
solved difference between variables in typescript