I got somewhere with the following method:
var value = 123456789.9876543 // i.e. some decimal number
var num2 = value.toString().split('.');
var thousands = num2[0].split('').reverse().join('').match(/.{1,3}/g).join(',');
var decimals = (num2[1]) ? '.'+num2[1] : '';
var answer = thousands.split('').reverse().join('')+decimals;
Using split-reverse-join is a sneaky way of working from the back of the string to the front, in groups of 3. There may be an easier way to do that, but it felt intuitive.