Skip to content

es6 transforms bug(Rest Params) #853

@magicismight

Description

@magicismight
function push(array, ...items) {
    array.push(...items);
}

The code above will throw an SyntaxError
Unexpected keyword 'var'.Expected an opening '{' at the start of a function body.

But if I write rest params separately,they are just fine.

function push(array, ...items) {
    array.push.apply(array, items);
}

OR

function push(array) {
    var args = [].slice.call(arguments);
    array.push.call(...args );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions