Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
.idea
25 changes: 13 additions & 12 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,47 @@ 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 () {
var obj = {
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()
})
})
})
});