let delay = (func, ms) => {
return function() {
setTimeout(func.bind(obj), ms, ...arguments);
}
}
let obj = {
value: `Alex`,
func: function(inner) {
console.log(`${this.value} ${inner}`);
}
};
let f1000 = delay(obj.func, 1000);
let f1500 = delay(obj.func, 1500);
f1000(`1`); // Alex 1
f1500(`2`); // Alex 2
let delay = (func, ms) => {
return function() {
setTimeout(func, ms, ...arguments);
}
}
...
let f1000 = delay(obj.func.bind(obj), 1000);