Skip to content

Instantly share code, notes, and snippets.

@ahmednuaman
Created July 21, 2014 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmednuaman/844922f2f27d61d3a235 to your computer and use it in GitHub Desktop.
Save ahmednuaman/844922f2f27d61d3a235 to your computer and use it in GitHub Desktop.
That's a naughty JS dev
describe('scoping', function () {
it('should correctly deal with scoping `this` back to the callee', function () {
var mod = new Module(),
request;
request = function (callback) {
return callback();
};
function Module () {
this.foo = 'bar';
}
Module.prototype.method = function() {
// return this.foo;
return 'bar';
};
Module.prototype.req = function() {
return request(this.method);
};
expect(mod.req()).toBe('bar');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment