From d63fd5e5d64c779f4ec5bf8a811aa615b8e78086 Mon Sep 17 00:00:00 2001 From: louly Date: Sun, 4 Aug 2019 12:30:47 +0800 Subject: [PATCH] lly: preview --- .gitignore | 3 ++- test/test.js | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index b512c09..eb79dd5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +.idea diff --git a/test/test.js b/test/test.js index 63a72e4..260d031 100644 --- a/test/test.js +++ b/test/test.js @@ -4,21 +4,21 @@ describe('this', function () { say: function () { setTimeout(() => { // this 是什么?想想为什么? - this.should.equal(null) + this.should.equal(obj); done() }, 0) } - } + }; obj.say() - }) + }); it('global', function () { function test() { // this 是什么?想想为什么? - this.should.equal(null) + this.should.equal(global) } test() - }) + }); describe('bind', function () { it('bind undefined', function () { @@ -26,24 +26,25 @@ describe('this', function () { say: function () { function _say() { // this 是什么?想想为什么? - this.should.equal(null) + this.should.equal(global) } + // obj get undefined return _say.bind(obj) }() - } + }; obj.say() - }) + }); it('bind normal', function () { - var obj = {} + var obj = {}; obj.say = function () { function _say() { // this 是什么?想想为什么? - this.should.equal(null) + this.should.equal(obj) } return _say.bind(obj) - }() + }(); obj.say() }) }) -}) \ No newline at end of file +});