On Wed, Jan 16, 2019 at 5:29 PM ViliusCreator <viliuskubilius...@gmail.com> wrote: > You could use > > ```js > new Abc`abc`(‘abc’) > ```
I think you must have missed [my earlier reply]( https://esdiscuss.org/topic/proposal-class-templates#content-7), which covered that, and also the fact that the major problem with using `<>` for this is that it's already valid syntax (in a common use case) meaning something else (something almost nonsensical, but valid nonetheless). On Wed, Jan 16, 2019 at 5:41 PM ViliusCreator <viliuskubilius...@gmail.com> wrote: > Also, using `new (Abc(4, 5, 6))(1, 2, 3)` causes error ` Uncaught TypeError: Abc(...) is not a constructor`. Not if `Abc` is written correctly, for instance like Michał Wadas did with `SizedArray` earlier in this thread. `Abc` example: ```js const Abc = (a, b, c) => { // ...optionally do something with a, b, and c... // Return a class return class Abc$ { constructor(x, y, z) { this.x = x; this.y = y; this.z = z; } // ...optionally do something with a, b, and c... show() { console.log(`a = ${a}, b = ${b}, c = ${c}`); console.log(`x = ${this.x}, y = ${this.y}, z = ${this.z}`); } }; }; const obj = new (Abc(4, 5, 6))(1, 2, 3); obj.show(); ``` https://jsfiddle.net/gh3dv297/ -- T.J. Crowder
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss