相当于Number.prototype.toString = function(Digits) {
var val = Math.round(this * Math.pow(10, Digits)) /
 Math.pow(10, Digits);
var retStr = val.toString();

var pos = retStr.indexOf('.');
if (pos < 0) pos = retStr.length;

var digits = Digits - retStr.substr(pos + 1).length;
if (digits > 0) {
if (digits == Digits) retStr += '.';
for (i = 0; i < digits; i++) retStr += '0';
}

return retStr;
}
意思是给Number的原形对象添加一个toString方法
Number对象本身已经有toString方法,所以会有这个来覆盖原有的.

解决方案 »

  1.   

    extend()方法
    prototype属性
    js里边的仔细研究
      

  2.   

    cancelBubble的用法
    防止重叠的元素的事件被逐级上传,如果下面的代码不使用event.cancelBubble=true;则document.onclick也能感知到鼠标点击事件
      <script   language="javascript">  
      function   document.onclick()  
      {  
          alert("document感知到的");  
      }  
       
      function   clickMe()  
      {  
          alert("按钮感知到的");  
          event.cancelBubble   =   true;  
      }  
      </script>    
       
      <input   type="button"   value="click   me"   onclick="clickMe()">
      

  3.   

    <xmp>的用法
    <xmp>
    <font color="#0000FF">姓名:</font><input type="text" name="textbox1" size="24">
    </xmp>
    在IE上执行的时候,不对xmp之间的内容做解析,直接当作字符显示出来,会看到
     
    如果在首尾加上控制,还能把这些内容变成红颜色
    <font color=red>
    <xmp>
    <font color="#0000FF">姓名:</font><input type="text" name="textbox1" size="24">
    </xmp>
    </font>
     
      

  4.   

    数组可以这么赋值
    直接赋值成多维数组
    <script>
    var s=["你好",["中国","太原","邢志云"],[3,3333],[4,4444],[5,5555],["0",["a","b","c"]],"cc"];
    //        0               1                   2       3        4             5            6
    //                  10    11       12     20  21   30  31    40  41alert(s);//你好,中国,太原,邢志云,3,3333,4,4444,5,5555
    alert(s[1]);//中国,太原,邢志云
    alert(s[1][2]);//邢志云
    alert(s[2][0]);//3
    alert(s[2][1]);//3333
    alert(s[5][1][0]);//a
    alert(s[5][1][2]);//c
    alert(s[6]);//cc
    </script>
      

  5.   

    对Object中的Number对象的toString()方法做了扩展,重写了该方法。
      

  6.   

    var obj ={};
    表示定义一个对象实例.
    理解这句就理解全部了.
      

  7.   

    看一看Prototype JavaScript framework的源代码:Object.extend = function(destination, source) {
      for (property in source) {
        destination[property] = source[property];
      }
      return destination;
    }你会对"zhaoxiaoyang(梅雪香@深圳)" 的解释有更深入的理解。