Spread Syntax

  The spread syntax allows an expression to be expanded in places where multiple arguments are expected.

  Spread Syntax

1、为了将[]传递给一个函数,过去使用apply方法

  Spread Syntax

  ES2015后,可以使用spread语法:

  Spread Syntax

  一个更复杂的例子

  Spread Syntax

2、一个array组合另一个array

  Spread Syntax

3、连接两个array。

  过去这么干:

  Spread Syntax

  现在可以这么干:

  Spread Syntax

4、unshift.

  过去:

  Spread Syntax

  现在:

  Spread Syntax

  

  Note that the spread operator can be applied only to iterable objects:

参考:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator

相关文章:

  • 2021-07-08
  • 2021-06-17
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2021-08-26
  • 2021-06-29
相关资源
相似解决方案