clojurescript

In ClojureScript, What is the difference between `int?` and `integer?` and `number?`?


In ClojureScript, What is the difference between int? and integer? and number? ?


Solution

  • number? does what is equivalent to typeof x === 'number' in JS.

    integer? does that, plus also checks if it's not a NaN, not an Infinity, and has no fraction part (i.e. a regular integer value, not a float).

    int? is a disjunction of the checks for integer?, an instance of goog.math.Integer, and an instance of goog.math.Long.

    The source code of all of the functions is very straightforward - I definitely recommend checking it out.