I keep losing this, even though it's one of my more enjoyable StackOverflow answers. So here it is.
Take in the number. Multiply by significant digits after the decimal so that you can truncate to zero places with ~~. Divide that multiplier back out. Profit.
function truncator(numToTruncate, intDecimalPlaces) {    
    var numPower = Math.pow(10, intDecimalPlaces);
    return ~~(numToTruncate * numPower)/numPower;
 Though there might be a better answer just south.

Labels: , ,