在ClojureScript中检查NaN

Ada*_*deg 11 clojure nan clojurescript

如何检查值是否为NaN?我更喜欢一种可以在Clojure中使用的解决方案,而且没有太多额外的东西(因此我不想使用外部库,例如下划线).这是我试过的

(number? js/NaN) ;=> true, well I'd expect false
(= js/NaN (js/parseInt "xx")) ;=> false
(= js/NaN js/NaN) ;=> false, even worse

; This is the best I could come up with
(defn actual-number? 
  [n] 
  (or (> 0 n) (<= 0 n)))
Run Code Online (Sandbox Code Playgroud)

Joo*_*aat 21

你不应该比较NaN的 - 他们总是不平等.你应该可以使用javascript的内置isNaN函数

(js/isNaN x)
Run Code Online (Sandbox Code Playgroud)