From 75854dd8fcb152ec09c48b5b4abb9027b5603042 Mon Sep 17 00:00:00 2001 From: huxuedong <1208442852@qq.com> Date: Tue, 9 Jan 2024 10:28:27 +0800 Subject: [PATCH] Update 1.2.4.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bind的实现有一个小问题 --- 1/1.2.4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1/1.2.4.md b/1/1.2.4.md index c108d31..8d8252e 100644 --- a/1/1.2.4.md +++ b/1/1.2.4.md @@ -545,7 +545,7 @@ Function.prototype.myBind = function(objThis, ...params) { //对返回的函数 secondParams 二次传参 let funcForBind = function(...secondParams) { //检查this是否是funcForBind的实例?也就是检查funcForBind是否通过new调用 - const isNew = this instanceof funcForBind; + const isNew = this instanceof thisFn;//注意:此处funcForBind的原型指向thisFn.prototype //new调用就绑定到this上,否则就绑定到传入的objThis上 const thisArg = isNew ? this : Object(objThis);