Nodejs Currency Parse fromCurrency()

Here you can find the source of fromCurrency()

Method Source Code

String.prototype.fromCurrency = function() {
  /**//from  ww  w. j  a  v  a2  s . c o  m
   * Return a Number representation of a currency string,
   * e.g 12,345.67 => 12345.67
   * Return NaN if the string is non-numerical.
   */
  return Number(this.replace(/,/g, ''));
};

Related

  1. fromCurrency()
    String.prototype.fromCurrency = function() {
      var pattern = /,\s*/g;
      return parseFloat(this.replace(pattern, ""));
    };
    
  2. fromCurrency()
    String.prototype.fromCurrency = function(){
      var num = this.replace(/\,/g, "");
      return parseFloat(num);
    };
    
  3. fromCurrency()
    String.prototype.fromCurrency = function() {
      return Number(this.replace(/,/g, ""));