Skip to content

Instantly share code, notes, and snippets.

@gartz
Last active September 14, 2015 12:57
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 gartz/9d14cc6190e23808c08e to your computer and use it in GitHub Desktop.
Save gartz/9d14cc6190e23808c08e to your computer and use it in GitHub Desktop.
bind test
// Begin with:
delete Function.prototype.bind;
function bind(/* ... */){
/* ... */
}
// Ends with:
Function.prototype.bind = bind;
// Tests:
var a = {};
var b = {};
var f = function(){ return {context: this, args: arguments}; };
d = f.bind(a);
e = f.bind(b, 1, 2, 3);
console.log('Tests result: ', d().context === a && e().context === b && e('test').args[3] === 'test' && d.call(b).context === a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment