diff --git a/test/test.js b/test/test.js index 63a72e4..fe40b75 100644 --- a/test/test.js +++ b/test/test.js @@ -1,10 +1,11 @@ +const should = require('should'); describe('this', function () { it('setTimeout', function (done) { var obj = { say: function () { setTimeout(() => { - // this 是什么?想想为什么? - this.should.equal(null) + // this 是什么?想想为什么?(obj) + this.should.equal(obj) done() }, 0) } @@ -14,8 +15,8 @@ describe('this', function () { it('global', function () { function test() { - // this 是什么?想想为什么? - this.should.equal(null) + // this 是什么?想想为什么?(windows) + this.should.equal(global) } test() }) @@ -25,8 +26,8 @@ describe('this', function () { var obj = { say: function () { function _say() { - // this 是什么?想想为什么? - this.should.equal(null) + // this 是什么?想想为什么?(obj) + this.should.equal(global) } return _say.bind(obj) }() @@ -38,8 +39,8 @@ describe('this', function () { var obj = {} obj.say = function () { function _say() { - // this 是什么?想想为什么? - this.should.equal(null) + // this 是什么?想想为什么?(obj) + this.should.equal(obj) } return _say.bind(obj) }()