當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
js isinteger_在JavaScript中使用示例使用Number isInteger()方法
生活随笔
收集整理的這篇文章主要介紹了
js isinteger_在JavaScript中使用示例使用Number isInteger()方法
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
js isinteger
編號isInteger()方法 (Number isInteger() Method)
isInteger() is a Number Method, it is used to check whether a given number is an integer or not.
isInteger()是一個(gè)數(shù)字方法,用于檢查給定數(shù)字是否為整數(shù)。
It returns true if given number is an integer, if given number is not an integer – it returns false.
如果給定數(shù)字是整數(shù),則返回true;如果給定數(shù)字不是整數(shù),則返回–返回false 。
Syntax:
句法:
Number.isInteger(number);Examples:
例子:
Input: 10Output: trueInput: 10.23Output: falseInput: "Hello"Output: FalseCode:
碼:
<html> <head> <title>JavaScipt Example</title> </head> <body> <script>document.write("10: " + Number.isInteger(10) + "<br>");document.write("10.23: " + Number.isInteger(10.23) + "<br>");document.write("Hello: " + Number.isInteger("Hello") + "<br>");//checking with variablesvar a = 10;var b = 10.23;var c = "Hello";if(Number.isInteger(a)==true)document.write(a + " is an integer value" + "<br>");elsedocument.write(a + " is not an integer value" + "<br>");if(Number.isInteger(b)==true)document.write(b + " is an integer value" + "<br>");elsedocument.write(b + " is not an integer value" + "<br>");if(Number.isInteger(c)==true)document.write(c + " is an integer value" + "<br>");elsedocument.write(c + " is not an integer value" + "<br>"); </script> </body> </html>Output
輸出量
10: true 10.23: false Hello: false 10 is an integer value 10.23 is not an integer value Hello is not an integer value翻譯自: https://www.includehelp.com/code-snippets/number-isInteger-method-with-example-in-javascript.aspx
js isinteger
總結(jié)
以上是生活随笔為你收集整理的js isinteger_在JavaScript中使用示例使用Number isInteger()方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 颐和园游览攻略线路
- 下一篇: 杭州看男性不育最好的医院推荐