9951 explained code solutions for 126 technologies


javascriptFormat number thousands separators


var num = 1234567;
num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ');ctrl + c
var num

declare test number

num.toString()

converts number to string

replace

regex to replace every 3 symbols to a given character (source)

' '

character to separate thousands (space in our example)