运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Numbers</h1> <h2>The Number.isFinite() Method</h2> <p>Number.isFinite() returns true if the value is a finite, legal number:</p> <p id="demo"></p> <p>Number.isFinite() is not supported in Internet Explorer.</p> <script> let res = ""; res += Number.isFinite(5-2) + ": 5-2<br>"; res += Number.isFinite(5/2) + ": 5/2<br>"; res += Number.isFinite(0) + ": 0<br>"; res += Number.isFinite(0/0) + ": 0/0<br>"; res += Number.isFinite(Infinity) + ": Infinity<br>"; res += Number.isFinite(-Infinity) + ": -Infinity<br>"; res += Number.isFinite(NaN) + ": NaN<br>"; document.getElementById("demo").innerHTML = res; </script> </body> </html>