This should work on any browser that supports locales and the options described on MDN:
return input.toLocaleString("en", {
useGrouping: true,
maximumFractionDigits: 8
});
And here's an alternative solution adapted from Elias Zamaria's answer here:
var x = input.toFixed(8).split('.');
return x[0].replace(/\B(?=(\d{3})+(?!\d))/, ',') +
('.' + x[1]).replace(/\.?0+$/, '');