Javascript number to number with commas trick

Came across this simple function that works nice in After Effects:

function numberWithCommas(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }

Now you can have rolling counters by just adding a custom slider control and keyframing the start and end values.