Spread Syntax vs Rest Parameter in ES2015 / ES6

前端 未结 10 1792
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 10:52

I am confused about the spread syntax and rest parameter in ES2015. Can anybody explain the difference between them with proper examples?

10条回答
  •  庸人自扰
    2020-11-27 11:29

    Basically like in Python:

    >>> def func(first, *others):
    ...    return [first, *others]
    >>> func('a', 'b', 'c')
    ['a', 'b', 'c']
    

提交回复
热议问题