看板 Ajax 關於我們 聯絡資訊
I have practiced Javascript for a long long time, and there's always a contradiction, which has confused me so much. That is, why NaN and Infinity are both types of “number”? In mathematics,“Infinity”is just a concept, not a number. “NaN”means“Not a number”on its literal meaning. Obviously those are not“numbers.” However, in Javascript, both“NaN”and“Infinity”are“number.” You can try it like below: typeof NaN // Returns“number” typeof Infinity // Returns“number” So what's the reason? Could someone tell me the reason about this weird contradiction? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.145.142.148 ※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1500617454.A.083.html
ssccg: 不然你覺得是什麼type? 07/21 14:19
ssccg: 實作上來說這些只是特別的數字,可參考IEEE754 07/21 14:32
DolphinLinn: NaN is number type, and NaN != NaN 07/21 22:58
aspdoctor: 白馬是馬,白馬也非馬,就這個意思 07/22 01:27
Qiqi: 樓上不如講 色即是空,空即是色 07/24 10:07
visa9527: 就像 '' 也是 string 啊,明明就是空的東西 07/24 15:20
hijkxyzuw: 浮點數裡有定義 NaN ,所以在 C 裡也能用。 07/25 22:33
VdustR: null 也是 object 阿 07/30 03:24