Some ES5 code doesn't use ES5 to the fullest
webbedspace opened this issue · comments
Lexical this could be written as:
this.nums.forEach(function (v) {
if (v % 5 === 0)
this.fives.push(v);
}.bind(this));
Default parameter values could be written as:
function f (x, y, z) {
if (y === undefined)
y = 7;
if (z === undefined)
z = 42;
return x + y + z;
}
f(1) === 50;
Yes, good catch. The .bind() exists since ECMAScript 5.1. I've added this variant now, too. The direct comparison against "undefined" is also ok. Code changed this way, too. Thanks for your feedback.