duktape
duktape copied to clipboard
Implement ES2015 extended function argument handling
I noticed that there was no bug reports to specifically request adding these Features...
- [ ] Add Support for Default Parameter Values This is relatively easy, and there is two main ideas on this...
// ES6 - new way
function f (x, y = 7, z = 42) {
return x + y + z;
}
f(1) === 50;
- [ ] Add Support for aggregation of remaining arguments into a single parameter.
// es6 - New Method
function f (x, y, ...a) {
return (x + y) * a.length;
}
f(1, 2, "hello", true, 7) === 9;
- [ ] Add Support for Spread Operator.
// es6 - New Method
var params = [ "hello", true, 7 ];
var other = [ 1, 2, ...params ];
// [ 1, 2, "hello", true, 7 ]
function f (x, y, ...a) {
return (x + y) * a.length; }
f(1, 2, ...params) === 9;
var str = "foo";
var chars = [ ...str ]; // [ "f", "o", "o" ]
Note: The above examples are general ideas
@kphillisjr Renamed the issue because ES2015 support is a longer term target so it's not a feature request as such. There isn't a full set of Github issues addressing all the ES2015 feature gaps because that would be a lot of individual issues.
Related discussion of some implementation details in #1344.
Does this come true now?
@svaarala
These are not implemented yet.
aggregation of remaining arguments into a single parameter.This feature is urgently needed.Can you support it as soon as possible?
I can't promise a specific time, it all depends on how much free time I (or others) have to spend on development. In the meanwhile you can use transpiling, e.g. Babel, to get most of the post-ES5.1 features.