Skip to content

Spread operator in 'new' expressions support for ES5? #2369

Closed
@saschanaz

Description

@saschanaz

I've found that #1931 supports this only for ES6, but it seems ES5 also can do this in any way.

var arguments = [1, 2, 3, 4, 5];
new Array(...arguments);

This can be converted to ES5:

// Thanks to: http://stackoverflow.com/a/14378462/2460034
var arguments = [1, 2, 3, 4, 5];
new (Array.bind.apply(Array, [null].concat(arguments)));
// Result: [1, 2, 3, 4, 5]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions