JavaScript/变量提升:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
第30行: 第30行:
Uncaught ReferenceError: i is not defined
Uncaught ReferenceError: i is not defined
     at <anonymous>:6:13</pre>}}}}
     at <anonymous>:6:13</pre>}}}}
== 变量提升 ==
字节的一道面试题
{{leftrightflex|<syntaxhighlight
lang="javascript">
window.name = 'ByteDance';
function A () {
  this.name = 123;
}
A.prototype.getA = function(){
    console.log(this);
    return this.name + 1;
}
let a = new A();
let funcA = a.getA;
funcA();
</syntaxhighlight>|{{consoleout|<pre>
ByteDance1
</pre>}}}}

2020年12月2日 (三) 12:30的版本

引言

提升

模板:Leftrightflex

避免提升

模板:Leftrightflex

变量提升

字节的一道面试题 模板:Leftrightflex