zoukankan      html  css  js  c++  java
  • JavaScript——JS上下文中的this值笔记

    阅读文章:http://www.w3cplus.com/js/javascript-this-different-contexts.html

    此篇文章由Sunnylost根据Louis Lazaris的英文文章原名《JavaScript ‘this’ in Different Contexts》进行翻译,英文出处:http://www.impressivewebs.com/javascript-this-different-contexts

    ——作者:Louis Lazaris,译者:Sunnylost

      个人总结

    1. 在全局上下文中this指向window对象
    2. 在函数上下文中this值取决于你是否使用了严格模式,没有严格模式,this依然指向window对象,采用严格模式("use strict")将使 this 值变成undefined而不是全局对象的引用
    3. 在模块模式中每一个单独方法(即函数)中,this 将引用整个模块
    4. 对于一个嵌套函数,如果包含了一个匿名函数,this就变成全局对象window的引用
  • 相关阅读:
    如何写Makefile?
    C语言变量的存储类别详解
    Longest Palindrome Substring
    Count Primes
    Closest Binary Search
    Search Insert Position
    Set Matrix Zeros ****
    Search for a Range
    Two Sum II
    Jump Game
  • 原文地址:https://www.cnblogs.com/vico/p/2888127.html
Copyright © 2011-2022 走看看