From 26452883f4bad43a39d9afd5a0ddba27c6b03762 Mon Sep 17 00:00:00 2001 From: qianguyihao Date: Wed, 4 Dec 2019 23:00:00 +0800 Subject: [PATCH] =?UTF-8?q?update:=20JS=E9=A2=84=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-JavaScript基础/10.2-预编译及变量提升详解.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/04-JavaScript基础/10.2-预编译及变量提升详解.md b/04-JavaScript基础/10.2-预编译及变量提升详解.md index 8ca3002..019b9b7 100644 --- a/04-JavaScript基础/10.2-预编译及变量提升详解.md +++ b/04-JavaScript基础/10.2-预编译及变量提升详解.md @@ -37,16 +37,21 @@ function foo() { foo(); -console.log(window.a); // 在全局范围内访问 a console.log(window.b); // 在全局范围内访问 b +console.log(window.a); // 在全局范围内访问 a +console.log(a); // 在全局范围内访问 a,但是前面没有加 window 这个关键字 + ``` 上方代码的打印结果: ``` +100 + undefined -100 +(会报错,提示 Uncaught ReferenceError: a is not defined) + ``` **解释**: