Apply,Call,Bind
Apply,Call,Bind JavaScript differences
by Reddy Uppathi
JavaScript
// Apply,Call,Bind JavaScript differences
var person = {
name: "James Smith",
hello: function(thing) {
alert(this.name + " says hello " + thing);
}
}
//person.hello("world"); // output: "Call Smith says hello world"
person.hello.call({ name: "Call" }, "world");
//person.hello.apply(person, arguments);
//person.hello.apply({ name: "Jim Smith12" }, "world2");
var helloFunc = person.hello.bind({ name: "Bind" });
helloFunc("world"); // output: Bindsays hello world"