Nodejs Utililty Methods Number Format

List of utility methods to do Number Format

Description

The list of methods to do Number Format are organized into topic(s).

Method

numberFormat()
String.prototype.numberFormat = function() {
    return this.replace(/(\d)(?=(?:\d{3})+(?!\d))/g,'$1,');
};
numberWithCommas()
String.prototype.numberWithCommas = function () {
  if (typeof parseFloat(this) === "number") {
    thiss = (Math.round((this) * 100) / 100).toString();
    var dotLastIndex = this.lastIndexOf(".");
    if (dotLastIndex === -1) {
      thiss = this + ".00"
    } else {
      var decimal = this.substring(dotLastIndex+1);
      var nonDecimal = this.substring(0, dotLastIndex);
...