format numbers in javascript with group digits


/ Published in: JavaScript
Save to your folder(s)

format numbers in javascript with group digits


Copy this code and paste it in your HTML
  1. Number.prototype.format = function () {
  2. return this.toString().split( /(?=(?:\d{3})+(?:\.|$))/g ).join( "," );
  3. };

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.