To achieve maximum efficiency, it is recommended to maintain the number in its original form (unformatted) for all calculations and operations, and only convert it to a formatted string for presentation purposes.
If you do wish to convert a formatted number (1,00,0000
) back to an integer, you can utilize the following code snippet.
var formattedNumber = "1,00,000";
var number = parseInt(formattedNumber.replace(/,/g, ''), 10);
In case your number includes decimal points, you can use the code below.
var formattedNumber = "1,00,000.99";
var number = parseFloat(formattedNumber.replace(/,/g, ''));