
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
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 Articles
- 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?
- How to convert a string to a floating point number in JavaScript?
- Why does Array.map(Number) convert empty spaces to zeros? JavaScript
- How to remove leading zeros from a number in JavaScript?
- How to convert a date object to string with format hh:mm:ss in JavaScript?
- How to convert a String containing Scientific Notation to correct JavaScript number format?
- How to convert a string to JavaScript object?
- How to convert a currency string to a double with jQuery or JavaScript?
- How to get a string left padded with zeros in Python?
- How to convert a string in to a function in JavaScript?
- How to convert string to number in TypeScript?
- How to convert a string to camel case in JavaScript?
- How to convert a string into number in PHP?

Advertisements