Usage of rest parameter and spread operator in javascript

后端 未结 6 1866
时光取名叫无心
时光取名叫无心 2020-11-30 05:15

What\'s the usage of rest parameter that will be added in ECMAScript 6?

For example, in ECMAScript 5 you can do the following to get an array of parameters starting

6条回答
  •  一整个雨季
    2020-11-30 05:33

    Is the difference between them is just syntax or there's a performance issue?

    Both, and more...

    Rest parameters:

    1. Are a known idiom in other languages (Ruby, Python).
    2. Are esier to read and maintain (vs. slice).
    3. Are easier to understand for beginners.
    4. Can (and likely will) result in better performance, since engines can optimize.
    5. Are tool friendlier, as they can be analyzed statically.

提交回复
热议问题