减小字体 增大字体
] 源码如下----------------------------------------------------------<script>//任意位四舍五入Number.prototype.round=function(n){//code by windy_sk , seasonx@163.netif(!/\d/.test(n))return this;var num = this * Math.pow(10,n);alert(num);return Math.round(num)/ Math.pow(10,n);}alert((1.237802456).round(3))//阶乘Number.prototype.fact=function(){//code by windy_sk , seasonx@163.netvar num = Math.floor(this);if(num<0)return NaN;if(num==0 || num==1)return 1;elsereturn (num*(num-1).fact());}alert((4).fact())</script>
[提示:你可先按照下面代码提示修改 上面部分代码,再按运行,此处看到的演示不完全正确]