Javascript get number with comma and two decimal places

In Javascript, how to get a number with a comma and two decimal places:

function numberWithCommaTwoDecimalPlaces(number) {
    var formattedNumber = number.toLocaleString('en-US', 
                            { 
                                style: 'decimal', 
                                maximumFractionDigits : 2, 
                                minimumFractionDigits : 2 
                            });
    return formattedNumber;
}

var number = 123434.5;

Will display as:

123,434.50

Comments are closed.