简体   繁体   English

TypeError: (fn) 仅在执行 function 时不可迭代

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

So I have a very simple code:所以我有一个非常简单的代码:

// 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);
});

Also tried this['executeNativeCommand'] — it worked.还尝试this['executeNativeCommand'] - 它有效。 What sort of magic is it?这是什么魔法?

The message is wrong and confusing, it should be tasks[i].args is not iterable / task.args is not iterable .消息错误且令人困惑,应该是tasks[i].args is not iterable / task.args is not iterable

You probably ran into this V8 bug .您可能遇到了这个 V8 错误

It was fixed three months ago (February 2020), but it seems it hasn't landed in stable node.js or Chrome yet.它是在三个月前(2020 年 2 月) 修复的,但它似乎还没有登陆稳定的 node.js 或 Chrome。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM