ในการตรวจสอบว่าค่าเป็นตัวเลขใน JavaScript หรือไม่ ให้ใช้วิธี isInteger() วิธีนี้จะตรวจสอบว่าค่านั้นเป็นตัวเลขหรือไม่
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อตรวจสอบว่าค่าเป็นตัวเลขหรือไม่ -
<html>
<head>
<title>JavaScript isInteger() Method </title>
</head>
<body>
<script>
document.write(Number.isInteger(30));
document.write("<br>"+Number.isInteger(true));
document.write("<br>"+Number.isInteger(false));
document.write("<br>"+Number.isInteger(-30));
</script>
</body>
</html>