DEV Community

Discussion on: Day 8 : Learning JS fundamentals, Part -3

Collapse
 
marzelin profile image
Marc Ziel

If you bind a function:

const bound = function () {
   console.log(this);
}.bind({type: "bound"});
Enter fullscreen mode Exit fullscreen mode

then no matter how you call the function (except new).
You can use .:

const o = { bound, type: "dot notation" };
o.bound();
Enter fullscreen mode Exit fullscreen mode

apply or call:

bound.call({type: "call"});
Enter fullscreen mode Exit fullscreen mode

or even call it directly:

bound();
Enter fullscreen mode Exit fullscreen mode

but this will always be the bound object: {type: "bound"}.

Thread Thread
 
gauravshekhawat profile image
Gaurav-Shekhawat

thank you so much for your assistance