From d63c860c073c4a6ab290ca210eea377717252885 Mon Sep 17 00:00:00 2001 From: Zeki Date: Fri, 16 Apr 2021 21:21:58 +0800 Subject: Fix Arrow_functions doc page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix line:210. The program notes should be printed out // 印出 undefined, Window {...} (or the global object) fix line:223. The program notes add ',' --- .../web/javascript/reference/functions/arrow_functions/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'files/zh-tw/web') diff --git a/files/zh-tw/web/javascript/reference/functions/arrow_functions/index.html b/files/zh-tw/web/javascript/reference/functions/arrow_functions/index.html index 8eac06ba55..82285afeae 100644 --- a/files/zh-tw/web/javascript/reference/functions/arrow_functions/index.html +++ b/files/zh-tw/web/javascript/reference/functions/arrow_functions/index.html @@ -207,7 +207,7 @@ var obj = { console.log(this.i, this); } } -obj.b(); // 印出 undefined, Object {...} +obj.b(); // 印出 undefined, Window {...} (or the global object) obj.c(); // 印出 10, Object {...}

箭頭函式並沒有自己的 this。另一個例子與 {{jsxref("Object.defineProperty()")}} 有關:

@@ -220,7 +220,7 @@ var obj = { Object.defineProperty(obj, 'b', { get: () => { - console.log(this.a, typeof this.a, this); // undefined 'undefined' Window {...} (or the global object) + console.log(this.a, typeof this.a, this); // undefined, 'undefined', Window {...} (or the global object) return this.a + 10; // represents global object 'Window', therefore 'this.a' returns 'undefined' } }); -- cgit v1.2.3-54-g00ecf