

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check if a variable is an integer in JavaScript?
To check if a variable is an integer, check the value using parseInt() and check with === operator.
Example
You can try to run the following code to check the existence of an integer −
<html> <head> <script> var a = 10; if (a === parseInt(a, 10)) alert("Integer!") else alert("Not an integer!") </script> </head> <body> </body> </html>
- Related Questions & Answers
- How to check if a variable is an array in JavaScript?
- How to check if a variable is NaN in JavaScript?
- How to check if a variable is boolean in JavaScript?
- How do you check if a variable is an array in JavaScript?
- How to check if a variable exists in JavaScript?
- How to check if an array contains integer values in JavaScript ?
- How to check if an input is an integer using C/C++?
- How can I check if a JavaScript variable is function type?
- How do I check to see if a value is an integer in MySQL?
- Python - Check if a variable is string
- C++ Program to check if input is an integer or a string
- How to check if a variable is NULL in C/C++?
- Check if variable is tuple in Python
- How to check if type of a variable is string in Python?
- How to check if an object is an instance of a Class in JavaScript?
Advertisements