bind call apply
this explained
JavaScript
// check call vs apply vs bind
var person = {
firstName: "Bhupendra",
lastName: "Negi",
getFullName: function() {
var fullName = this.firstName + ' ' + this.lastName;
return fullName;
}
}
var logName = function(arg1,arg2) {
console.log("Logged :" + this.getFullName() );
console.log("-----arguments-----");
console.log(arg1);
console.log(arg2);
}
//logName();
// bind obj
var logNamePerson = logName.bind(person);
logNamePerson();
// call obj
logName.call(person,"en","es");
logName.apply(person,["ar","as"]);