3 ms·
Because writing: var self = this; foo(function(x) { return x + self.y; }); rather than: foo(x => x + this.y) is so much less error-pro
by jahewson 11y ago
Because writing:
var self = this;
foo(function(x) {
return x + self.y;
});
rather than:
foo(x => x + this.y)
is so much less error-prone?
- eueueu 11y agoThink about what would happen if you typo a single character in each example. If you miswrite "function" as "fnuction", you'll easily, quickly find out. If you miswrite => as >= it might take ages to track it down.
- wereHamster 11y agoThat's why you use static type checkers. If the function `foo` is defined as taking a function as its first argument (or even more precisely, a function which takes a number and returns a number), and you try to give it a boolean, then the static type checker will yell at you, and you'll just as easily find out as that fnuction typo.