

- 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 whether a value is a safe integer or not in JavaScript?
A safe integer is an integer represented as an IEEE-754 double-precision number. That would mean integers from (253 - 1) to -(253 - 1). To check whether a value is a safe integer or not in JavaScript, use the isSafeInteger() method.
Example
You can try to run the following code to check whether a value is a safe integer or not. It returns true for a safe integer and integer −
<!DOCTYPE html> <html> <body> <script> document.write("Checking for Safe Integer..."); document.write("<br>"+Number.isSafeInteger(765)); document.write("<br>"+Number.isSafeInteger(-765)); document.write("<br>"+Number.isSafeInteger('765')); document.write("<br>"+Number.isSafeInteger(false)); document.write(Number.isSafeInteger(Math.pow(2, 53) - 1)); </script> </body> </html>
- Related Questions & Answers
- How to find whether a provided number is safe integer or not in JavaScript?
- How to check whether a NaN is a NaN or not in JavaScript?
- How to check whether a number is finite or not in JavaScript?
- JavaScript: How to check whether an array includes a particular value or not?
- Check whether a number is a Fibonacci number or not JavaScript
- Check whether the entered value is a digit or not in Java
- Check whether the entered value is a letter or not in Java
- How to check whether a value is a number in JavaScript?
- How to check whether a key exist in JavaScript object or not?
- How to check whether a thread is alive or not in C#
- Check whether a character is Lowercase or not in Java
- Check whether a Stack is empty or not in Java
- Check whether a HashSet is empty or not in Java
- Check whether a character is Uppercase or not in Java
- How to check whether a number is prime or not using Python?
Advertisements