Professional Documents
Culture Documents
Call Apply Bind
Call Apply Bind
doThis.call(obj1, 5); // 15
-------------------------------------------------
apply
----------------------------------------------------------------
Bind :-
---------------------------------
-----------------------------------
var obj1 = {
name: "sam",
doSomething: function(){
return this.name;
}
}
//////Return Object
function getMenu(){
return this;
}
hrMenu = {menu:"pizza"};
aa = getMenu.bind(hrMenu);
aa() // {menu:pizza}