Greg Chu Technical History
Monday, February 29, 2016
JavaScript Bind
Ex 1
var a = {name:"bob"};
var b = {name: "john"};
function showName(){return this.name;};
showName.bind(a)();
showName.bind(b)();
Ex 2
function add(x,y){
return x + y;
}
var plus1 = add.bind(null,1);
console.log(plus1(5));
1 comment:
GregOh
February 29, 2016 at 12:09 PM
https://www.smashingmagazine.com/2014/01/understanding-javascript-function-prototype-bind/
Reply
Delete
Replies
Reply
Add comment
Load more...
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
https://www.smashingmagazine.com/2014/01/understanding-javascript-function-prototype-bind/
ReplyDelete