簡體   English   中英

TypeError: (fn) 僅在執行 function 時不可迭代

[英]TypeError: (fn) is not iterable when just executing a function

所以我有一個非常簡單的代碼:

// doesn't matter, just be sure that we have an array
const tasks = Array.isArray(result) ? [...result] : [result];

// works
for (let i = 0; i < tasks.length; i++) {
    this.executeNativeCommand(tasks[i].command, ...tasks[i].args);
}

// TypeError: this.executeNativeCommand is not iterable (cannot read property Symbol(Symbol.iterator))
tasks.forEach(task => {
    this.executeNativeCommand(task.command, ...task.args);
});

還嘗試this['executeNativeCommand'] - 它有效。 這是什么魔法?

消息錯誤且令人困惑,應該是tasks[i].args is not iterable / task.args is not iterable

您可能遇到了這個 V8 錯誤

它是在三個月前(2020 年 2 月) 修復的,但它似乎還沒有登陸穩定的 node.js 或 Chrome。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM