

- 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 convert a string with zeros to number in JavaScript?
Let’s say the following is our string”
var stringValue="453.000.00.00.0000";
To convert the above string with zeroes to number, use parseInt() along with replace() −
var numberValue = parseInt(stringValue.replace(/\./gm, ''));
Example
Following is the complete code −
var stringValue="453.000.00.00.0000"; var numberValue = parseInt(stringValue.replace(/\./gm, '')); console.log("Original value="+stringValue) console.log("After modification the value="+numberValue);
To run the above program, use the following command −
node fileName.js.
Here, my file name is demo239.js.
Output
The output is as follows −
PS C:\Users\Amit\javascript-code> node demo239.js Original value=453.000.00.00.0000 After modification the value=45300000000000
- Related Questions & Answers
- How to pad a number with leading zeros in JavaScript?
- How to convert Number to String in JavaScript?
- How to convert String to Number in JavaScript?
- Why does Array.map(Number) convert empty spaces to zeros? JavaScript
- How to convert a string to a floating point number in JavaScript?
- How to remove leading zeros from a number in JavaScript?
- How to get a string leftpadded with zeros in Python?
- How to convert a string to JavaScript object?
- How to convert a String containing Scientific Notation to correct JavaScript number format?
- How to convert a value to a string in JavaScript?
- Convert string to a number in Java
- How to convert a value to a number in JavaScript?
- How to convert a string into number in PHP?
- How to convert a currency string to a double with jQuery or JavaScript?
- How to convert a date object to string with format hh:mm:ss in JavaScript?
Advertisements