From 689081f7d8baec91a097842451d18a8a13953d24 Mon Sep 17 00:00:00 2001 From: ruanyf Date: Fri, 19 Feb 2016 13:47:54 +0800 Subject: [PATCH] =?UTF-8?q?docs(function):=20=E7=AE=AD=E5=A4=B4=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/function.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/function.md b/docs/function.md index efd3207..bc4856e 100644 --- a/docs/function.md +++ b/docs/function.md @@ -839,7 +839,7 @@ foo.call( { id: 42 } ); // id: 42 ``` -上面代码中,`setTimeout`的参数是一个箭头函数,100毫秒后执行。如果是普通函数,执行时`this`应该指向全局对象,但是箭头函数导致`this`总是指向函数所在的对象。 +上面代码中,`setTimeout`的参数是一个箭头函数,100毫秒后执行。如果是普通函数,执行时`this`应该指向全局对象`window`,但是箭头函数导致`this`总是指向函数所在的对象(本例是`{id: 42}`)。 下面是另一个例子。 @@ -858,7 +858,7 @@ var handler = { }; ``` -上面代码的`init`方法中,使用了箭头函数,这导致`this`总是指向`handler`对象。否则,回调函数运行时,`this.doSomething`这一行会报错,因为此时`this`指向全局对象。 +上面代码的`init`方法中,使用了箭头函数,这导致`this`总是指向`handler`对象。否则,回调函数运行时,`this.doSomething`这一行会报错,因为此时`this`指向`document`对象。 ```javascript function Timer () {