Skip to content

Instantly share code, notes, and snippets.

@arunprabug
Created January 6, 2019 14:36
Show Gist options
  • Save arunprabug/58c4da0bbd4c66d344b013b92f34ad03 to your computer and use it in GitHub Desktop.
Save arunprabug/58c4da0bbd4c66d344b013b92f34ad03 to your computer and use it in GitHub Desktop.
bind,apply,call
bind,apply,call
function foo(a,b){
console.log(arguments);
console.log('below is apply call')
boo.apply(null,arguments);
console.log('below is apply call')
boo.apply(null,[a,b]);
console.log('below is call')
boo.call(null,a,b);
var tempFoo = boo.bind(null,a,b);
console.log('below is bind call')
tempFoo();
console.log('below is normal call')
boo(a,b);
}
function boo(a,b){
console.log(a,b)
};
foo('arun','g');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment