9 ms·
You can use ES6 default parameters to implement options objects, so instead of: function foo(x, options) { var y = options.y | 0; return x + y;
by jahewson 12y ago
You can use ES6 default parameters to implement options objects, so instead of:
function foo(x, options) {
var y = options.y | 0;
return x + y;
}
You can write:
function foo(x, y = 0) {
console.log(x + y);
}
Problem solved!