为什么不能简化使用array.includes的回调?

考虑以下数据:

const filters = ["c", "1"];

const data = [
  {
    name: 'a',
    values: ["a", "b", "c"],
  },
  {
    name: "b",
    values: ["a", "z", "1"],
  },
  {
    name: "c",
    values: ["z", "y", "x"],
  }
];

为了获取值包含过滤器之一的数据数组中的所有对象,可以使用以下对象:

data.filter(entry => entry.values.some(v => filters.includes(v)));

根据我了解的javascript规则,您可以通过以下方式放弃.some()调用中的匿名/ lambda函数:

data.filter(entry => entry.values.some(filters.includes));

However, this doesn't work, as we get the error TypeError: Cannot convert undefined or null to object. However, doing the following makes it work also, but is redundant and I don't understand why it's necessary:

const inc = (v) => filters.includes(v);
data.filter(entry => entry.values.some(inc));

这是V8引擎中的错误(我已经在chrome控制台和nodejs中尝试过此错误),还是我不知道的技术限制?如果是这样,有人可以向我解释吗?

评论