0
if ((() => {
    let hasChrome = false;
    let hasBrowser = false;
    try {
        hasChrome = (typeof chrome === 'object' && chrome !== null && typeof chrome.runtime !== 'undefined');
    } catch (e) {
        // NOP
    }
    try {
        hasBrowser = (typeof browser === 'object' && browser !== null && typeof browser.runtime !== 'undefined');
    } catch (e) {
        // NOP
    }
    return (hasBrowser && !hasChrome);
})()) {
    chrome = browser;
}

Question 1: The code above seems an arrow function,but I wonder where is the name of the function? How to understand it?
Shouldn't arrow function like this?
hello = () => { return "Hello World!"; }

Question 2(sovled): One more question from anothor piece of code.
Is this defining a class 'Yomichan' and 'my_yomichan' as an object of class Yomichan?

const my_yomichan = (() => {
    class Yomichan extends EventDispatcher {
        constructor() {
            super();
            ...
            ...
            bla();
        }

        // Public

        bla();
    }
    return new Yomichan();
})();

Any assistance is highly appreciated and thanks in advance.

Ye Shiwei
  • 9
  • 5

0 Answers0