重写了toFixed
Number.prototype.toFixed = function(c){
var self = this,
re = Math.round(self * Math.pow(10,c)) / Math.pow(10,c) + "";
if( c==0 ) return re;
(re.indexOf(".") == -1) && (re += ".");
var length = re.split(".")[1].length,
_length = c - length;
if(_length > 0){
re += Math.pow(10,_length).toString().slice(1);
}
return re ;
}
原文:http://www.cnblogs.com/anson0415/p/4983220.html