javascript 基础系列(一)
闭包:
function 内部访问外部的variables
function f(){
alert(ysr);
}

报错了。
Certain language constructs block the error, for example typeof x works if there is no x (and returnsundefined), but that’s an exception.
特定的语言结构是可以阻塞(拦截)这种错误的,(不让这种错误弹出来!!)。 比如 : typeof ysr, 先用这种语言结构检测一下,就不会报错了!!
If a variable is set, but not found anywhere, then it is created in the outmost LexicalEnvironment, which iswindow.
function f() {
x = 5 // writing x puts it into window
}
Decorators is a great pattern of programming, because it allows to take an existing function and extend/modify it’s behavior.
There are two reasons why decorators are cool:
-
Decorators can be reused. The
doublingDecoratorcan be applied tominusanddivideas well assum. -
Multiple decorators can be combined for greater flexibility.
See the tasks below for more examples.


浙公网安备 33010602011771号