Here’s a piece of code that I cannot wrap my head around. It’s from a webextension called tabs, tabs, tabs
. Link to the whole extension code is here https://github.com/mdn/webextensions-examples/blob/master/tabs-tabs-tabs/tabs.js
Here’s the part that I don’t understand -
document.addEventListener("click", (e) => {
function callOnActiveTab(callback) {
getCurrentWindowTabs().then((tabs) => {
for (var tab of tabs) {
if (tab.active) {
callback(tab, tabs);
}
}
});
}
How does function callOnActiveTab
accept it’s own returned value as a parameter to itself? If it’s related to callback functions then please explain that too.
Thanks a lot!