Chapter4: Hoisting 变量附加到哪个层次的scope,由它们在哪里和如何声明(let, var)来决定. Function scope/Block scope都有相同的法则:任何变量在一个scope内声明,则这个变量附加到这个作用域上. 但有一个细节问题:当声明declarations出现在一个作用域中的不同的位置的时候,scope附加如何与declarations协作? Chicken or The Egg? temptation: a strong desire to hav…
Content What is Scope? Lexical Scope Function Vs. Block Scope Hoisting Scope Closures Appendix: Dynamic Scope Polyfilling Block Scope Lexical-this Thank You's Chapter1: What is Scope? In fact, the ability to store values and pull values out of variab…
第二章,作用域由一系列的bubbles组成.每一个都代表了一个container或bucket,装着被声明的identifiers(variables, functions).这些bubbles相互嵌套.这种嵌套是在开发阶段写完的. 什么制造了一个新的bubble? 只是函数吗?其他的JS结构可以创建bubbles of scope吗? Function Vs. Block Scope Scope From Functions 探索函数作用域和它的暗示implications. 函数作用域内的所…
2种主要的models for how scope work. 最普遍的是Lexical Scope. 另一种 Dynamic Scope.(在Appendix a中介绍.和Lexical Scope 进行对比) Lex-time lexical scope is scope that is defined at lexing time. lexical scope是基于变量和blocks of scope被创建(被你,在write time). 不知道这是啥玩意! 我的理解就是定义作用域的有效…
Chapter 1: What is Scope? 第一章:什么是作用域 One of the most fundamental paradigms of nearly all programming languages is the ability to store values in variables, and later retrieve or modify those values. In fact, the ability to store values and pull value…