为什么这个变量赋值抛出?

时间:2019-01-23 22:52:54

标签: javascript scope

let registerDropdownHandler = (options, handler) => {
    this.element.addEventListener('contextmenu', (e) => {
        e.preventDefault();
        e.stopPropagation();

        let options = options;
        if (this.additionalDropdownOptions) options.push(...this.additionalDropdownOptions);

        let dropdown = openDropdown(e.clientX, e.clientY, options);
        dropdown.onselect = function(name) {
            handler(name);
            if (this.additionalDropdownHandler) this.additionalDropdownHandler(name);
        };
    });
};

是的,我知道语句let options = options在这里是多余的,但是为什么会抛出?它将引发“未捕获的ReferenceError:未定义选项”。

0 个答案:

没有答案