One of the features introduced by ECMAScript 6 is the ability to indicate default values for unspecified parameters in JavaScript, e.g.
function foo(a = 2, b = 3) {
return a * b;
}
console.log(foo()); // 6
console.log(foo(5)); // 15
Now I'm wondering if it's possible to use default parameters also for functions created dynamically with the Function constructor, like this:
new Function('a = 2', 'b = 3', 'return a * b;');
Firefox 39 seems to already support default parameters (see here), but the line above is rejected as a syntax error.
a =2? It would be slightly more difficult to use, isn't it?