Javascript Number number_with_delimiter(delimiter)

Description

Javascript Number number_with_delimiter(delimiter)



Number.prototype.number_with_delimiter = function(delimiter) {
  var number = this + '', delimiter = delimiter || ',';
  var split = number.split('.');
  split[0] = split[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + delimiter);
  return split.join('.');
};



PreviousNext

Related