When a closure "captures" a variable it "lifts" the variable out of its local scope and effectively moves it into an anonymous object.
当一个闭包“捕获”一个变量时,它就会将这个变量提取出它的本地范围,移到一个匿名对象里。
The functions themselves only exist in the scope of the variable of which they are defined, so when that variable goes out of scope, so does the function.
函数本身仅存在于定义函数的变量范围内,因此当该变量超出范围时,函数也超出范围。
Watch the variables being used in a function. If you notice a function using an out-of-scope variable more than once, store it in a local variable and use that instead.
仔细检查函数中所有使用的变量,如果有一个变量不是当前作用域定义的,而且使用了不止一次,那么我们就应该把这个变量保存在局部变量中,而使用这个局部变量来进行读写操作。
Because tally is a local variable within the function, it is created anew with each call and falls out of scope and is destroyed automatically when each call returns.
由于tally是函数内的本地变量,它将在每次调用时重新创建并清空范围,并且在每个调用被返回时自动销毁。
But lambda expressions are treated as values and can therefore be stored in a variable and executed after the block in which the captured variable was declared has gone out of scope.
但是,lambda表达式被视为值,因此可存储在变量中并在将捕获的变量声明为超出范围的代码块执行之后执行。
Firefox 3.1 Beta 2 was somewhat surprising as local variable writes were very fast but performance degraded significantly once the variable was out of the local scope.
Firefox 3.1Beta2的表现有点出人意料,对于局部变量执行的效率非常高,但随着作用域层数的增加,效率便大打折扣。
Consider the example in Listing 1, where a closure is defined in a class, and then invoked after the object variable goes out of scope.
考虑清单1中的示例,其中closure定义为类,并且在对象超出范围之外后进行调用。
Local variables are faster to access than out-of-scope variables because they exist in the first variable object of the scope chain.
局部变量比域外变量快,因为它位于作用域链的第一个对象中。
To calculate the sum you need to declare a variable out of the for loop scope. so declare a variable say sum and after each input add price to sum.
计算你需要声明一个变量的循环范围的总和。所以声明一个变量表示和每个输入添加价格和后。
Use this function to clear variables of type VARIANTARG (or VARIANT) before the memory that contains the VARIANTARG is freed (as when a local variable goes out of scope).
使用这个函数去清除VARIANTARG(或VARIANT)类型的变量在内存包含的VARIANTARG被释放(当一个局部变量超出作用域时)。
Use this function to clear variables of type VARIANTARG (or VARIANT) before the memory that contains the VARIANTARG is freed (as when a local variable goes out of scope).
使用这个函数去清除VARIANTARG(或VARIANT)类型的变量在内存包含的VARIANTARG被释放(当一个局部变量超出作用域时)。
应用推荐