70 ms·
I think the author is looking for the `.bind` method of the .click function [1], which explicitly specifies which object to use as `this`. Using that their code
by bijection 9y ago
I think the author is looking for the `.bind` method of the .click function [1], which explicitly specifies which object to use as `this`. Using that their code would be
document.getElementById("eta-reduced").onclick = listener.click.bind(listener);
Which is a little clunky, but shorten than before. Alternatively, an arrow function would also get the job done:
document.getElementById("eta-reduced").onclick = e => listener.click();
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...