

- 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 get the length of a Number in JavaScript?
Use the toString() method to covert the Number to string, then the length() method gives you length.
Example
You can try to run the following code to learn how to get the length of a Number −
<!DOCTYPE html> <html> <body> <script> var num1 = 344; var num2 = 149856; document.write("Length of number "+num1+" = "+ num1.toString().length); document.write("<br>Length of number "+num2+" = "+ num2.toString().length); </script> </body> </html>
Output
Length of number 344 = 3 Length of number 149856 = 6
- Related Questions & Answers
- How to get the length of a string in JavaScript?
- How to get the length of an object in JavaScript?
- How to get the cosine of a number in JavaScript?
- How to get the sine of a number in JavaScript?
- How to get the tangent of a number in JavaScript?
- How to get the square root of a number in JavaScript?
- How to get the exponent power of a number in JavaScript?
- How to get the absolute value of a number in JavaScript?
- How to get the length of a string in Python?
- How to get the Length of a String in Java?
- How to get the arccosine (in radians) of a number in JavaScript?
- How to get the arcsine (in radians) of a number in JavaScript?
- How to get the arctangent (in radians) of a number in JavaScript?
- JavaScript get the length of select options(dropdown)?
- How to get the number of forms in a document with JavaScript?
Advertisements