<html>
 <body>
   <script>
    var arry=[1,2,3,4,5,6];
    alert((function(){     
     for(var i=0,ret=arry[0]; i<arry.length; i++)
     {
      ret = Math.max(ret,arry[i])
     }
     return ret;
    })());
    
    alert((function(){ return Math.max.apply(null,arry); })())
    </script>
    
  <input type="button" );
       
       
        var x=10;
    var o ={x:15};
    function foo()
    {
    alert(this.x);
    }
    foo();
    foo.call(o);
    </script>

 </body>
</html>

补充:当使用了fn.call(obj)方法以后,fn方法中的this所指向的对象即为obj对象。

 //***********************************//

function classA()
     {
      alert(this.msg);
     }  
     function classB(name,msg)
     {
      alert(name);
      this.msg = msg;
      classA.call(this);
     }
     classB("kro","我叫什么?")

 //***********************************//

 

相关文章:

  • 2021-04-26
  • 2021-04-16
  • 2021-12-25
  • 2021-09-24
  • 2021-06-02
  • 2021-12-27
  • 2021-12-08
  • 2021-10-02
猜你喜欢
  • 2022-01-09
  • 2021-06-17
  • 2021-07-07
  • 2021-10-16
  • 2021-08-05
  • 2021-07-24
  • 2021-04-03
相关资源
相似解决方案