Why isn't NaN finite?

后端 未结 5 821
萌比男神i
萌比男神i 2021-01-13 17:34

Testing the isFinite function I see that NaN is an infinite number (even if it\'s not a number :-)).

5条回答
  •  执念已碎
    2021-01-13 17:48

    As Dave Newton said, NaN is not a number, and then you have to consider that it isn't finite nor infinite. The same occurs to these:

    NaN > 0  // false
    NaN < 0  // false
    

    You might want to read these articles:

    • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN
    • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite

提交回复
热议问题