From 4961c94f2daa337b849a9d87d55213a0f5f31b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=80=AA=E5=85=BD?= <1370167984@qq.com> Date: Sun, 24 Mar 2019 16:38:59 +0800 Subject: [PATCH] finish --- test/test.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/test.js b/test/test.js index 63a72e4..1453223 100644 --- a/test/test.js +++ b/test/test.js @@ -4,7 +4,7 @@ describe('this', function () { say: function () { setTimeout(() => { // this 是什么?想想为什么? - this.should.equal(null) + this.should.equal(obj) done() }, 0) } @@ -15,7 +15,7 @@ describe('this', function () { it('global', function () { function test() { // this 是什么?想想为什么? - this.should.equal(null) + this.should.equal(global) } test() }) @@ -26,9 +26,10 @@ describe('this', function () { say: function () { function _say() { // this 是什么?想想为什么? - this.should.equal(null) + this.should.equal(global) } - return _say.bind(obj) + // console.log(obj, 'obj') // obj在定义前为undefined(变量提升) + return _say.bind(obj) // bind(undefined) === bind() }() } obj.say() @@ -39,7 +40,7 @@ describe('this', function () { obj.say = function () { function _say() { // this 是什么?想想为什么? - this.should.equal(null) + this.should.equal(obj) } return _say.bind(obj) }()