philchanet
6/27/2017 - 7:58 AM

Format numbers with separator

Format numbers with separator

var n = 1234567890;
String(n).replace(/(.)(?=(\d{3})+$)/g,'$1,')
// "1,234,567,890"
// Replace $1, with $1. or $1space to change separator