这个语法是什么意思 (...)

What does this syntax mean (...)

我正在投入理性反应。 在以下代码中:

let component = ReasonReact.statelessComponent("Component3");
let make = (~name, _children) => {
  ...component,
  render: self => <input type_="checkbox" />,
};

我不明白第 3 行中的 (...) 是什么意思。 当我删除它时,我收到一条错误消息:

 The record field component can't be found.

  If it's defined in another module or file, bring it into scope by:
  - Annotating it with said module name: let baby = {MyModule.age: 3}
  - Or specifying its type: let baby: MyModule.person = {age: 3}

该表示法称为 Spread Syntax。这是在 ES6 中引入的。

来自 MDN 文档的定义和示例。 Link 在底部。

扩展语法允许在需要零个或多个参数(用于函数调用)或元素(用于数组文字)的地方扩展数组表达式或字符串等可迭代对象,或者扩展对象表达式需要零个或多个键值对(对于对象文字)的地方

function sum(x, y, z) {
  return x + y + z;
}

const numbers = [1, 2, 3];

console.log(sum(...numbers));
// expected output: 6

console.log(sum.apply(null, numbers));
// expected output: 6

更多详情:Spread Syntax