JSFiddle - React, Tailwind, and code Playground
by smacky311
JavaScript
Number.prototype.add = methodize(add);
function methodize(func) {//a function that converts a binary function to a method
return function (x) {
//console.log(x);
console.log(this);
return func(x,this);
}
}
function add(x, y) {
return x + y;
}
console.log((3).add(4)); //7