HTML5 .bind(this) what?
Copy link to clipboard
Copied
I am trying to wrap my head around the HTML5 alternate code. I am trying to wrap my head around the .bind(this);
this.button_1.addEventListener("click", fl_ClickToGoToAndPlayFromFrame.bind(this));
I understand 'this' for the start and it is reffereing to this instance ( I think). But then the call to teh function adds .bind(this). What is the purpose of this when simply calling a function? I tried to revove it, but that casued it to no longer work.
Also, is the 'fl_' important to have in the function name?
Thanks.
Copy link to clipboard
Copied
Bind forces a function to execute in the desired context, which means the value of "this". Without it, all event handlers execute in the global context, which means "this" points to the browser window object. This is only a problem if the event handler uses "this". Apparently yours does.
Copy link to clipboard
Copied
Thank you for explaning it.

