Wednesday, 5 April 2017

How to use ES6 Object Spread Operator to assign arguments passed to a function as object properties? [duplicate]

This question already has an answer here:

I am using ES6 and Babel, I would like to know if there is a more concise way to rewrite the following function using rest/spread operators.

And how to set babel preset for that. Thanks guys.

 init(fields, file, res, req) {
    // I want the following mapping done automatically
    this.fields = fields;
    this.file = file;
    this.res = res;
    this.req = req;
},



via Radex

No comments:

Post a Comment