Function.prototype.defer = function(ms) {
// let f = this;
return function(...args) {
setTimeout(() => console.log(this), ms, ...args)
}
};
function f(a, b) {
console.log( a + b );
}
f.defer(2000)(1, 4);
Function.prototype.defer = function(ms) {
// let f = this;
return (...args) => {
setTimeout(() => console.log(this), ms, ...args)
}
};
function f(a, b) {
console.log( a + b );
}
f.defer(2000)(1, 4);