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