Skip to content

Instantly share code, notes, and snippets.

@DaveMBush
Last active Jul 11, 2016
Embed
What would you like to do?
function add(a,b){
return a + b;
}
var newFoo = add.bind(this,3,4);
console.log(newFoo());
function add(a,b){
return a + b;
}
var a = 3;
var b = 4;
var newFoo = add.bind(this,a, b);
a = 6;
b = 7;
console.log(newFoo());
function consoleLog(i){
console.log(i);
}
for(var i = 0;i < 10;i++){
setTimeout(consoleLog.bind(this,i),1000);
}
function ClassName(){
this.eventHandler = (function(){
}).bind(this);
}
function add(a,b,c) {
return a+b+c;
}
var addAgain = add.bind(this, 1, 2);
var result = addAgain(3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment