function func2method(f){
return function(y) {
return f(this, y);
};
}
Number.prototype.add = func2method(function(x, y){return x+y});
Why do I have to use brackets to call this method on a number?
For example, 3.add(4)
won't work while (3).add(4)
works perfectly fine.