'Why is the scope different in chrome extension's popup?

I'm experimenting with Google Chrome extensions. In a popup html I have a button that executes the readItalian function.

italianBtn.addEventListener("click", async () => {
  let [tab] = await chrome.tabs.query({ active: true, currentWindow: true });

  chrome.scripting.executeScript({
    target: { tabId: tab.id },
    function: readItalian,
  });
});

const readItalian = () => readPage("it");

function readPage(targetLanguage) {
  //
}

The console says that readPage is not defined. It seems that there is a different scope. How does this work?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source