2 ms·
Sadly it is different because of the magic of this. If you set something equal to document.querySelector and then call it this will no longer refer to document.
by iudqnolq 7y ago
Sadly it is different because of the magic of this. If you set something equal to document.querySelector and then call it this will no longer refer to document. There are fancier ways with Function.prototype.bind, but wrapping in a function is the easiest conceptually.
https://www.taniarascia.com/this-bind-call-apply-javascript/ https://www.taniarascia.com/this-bind-call-apply-javascript/
For this specific case, you can see this at https://stackoverflow.com/q/13383886/8334056 https://stackoverflow.com/q/13383886/8334056