[Solved] difference between variables in typescript


Regarding your updated code:

const limit = !options.limit || options.limit === NaN ? 0 : options.limit
  • If options.limit is falsy, this will set limit = 0. Else, it will use options.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 if options.limit is NaN. You need to use isNaN() or Number.isNaN() to check for NaN

Your current code is equivalent to:

const limit = options.limit || 0.

3

solved difference between variables in typescript