zoukankan      html  css  js  c++  java
  • 这是关于JS this的最短一篇

    Javascript 的 this 不同于其它编程语言的 this 。

    this可以出现在任何位置。如果是全局下,  this 是 window ,不能更改的。

    定理: 代码是这样的: c.a()  那么 a函数里面的this就是 c       

    默认下, window.a() 是可以省略为 a() 的 所以 直接 a() , this是 window。

    代码是这样的: new a() 那么 a函数里面的是this就是a.prototype复制版本,且,new a()的默认返回就是这个复制版本。

    a.call 和 a.apply 可以改变默认的this行为, a.call(b, 参数1,...,参数n) 和 a.apply(b, 参数数组) 执行时, a里的 this 是 b。

  • 相关阅读:
    Task Schedule
    Number Game
    CDQ分治
    Friends and Subsequences
    HDU5266 pog loves szh III
    P1593 因子和
    求一个数的欧拉函数的优化
    Grandpa's Estate POJ
    LightOJ
    Paint The Wall HDU
  • 原文地址:https://www.cnblogs.com/xuld/p/2087971.html
Copyright © 2011-2022 走看看