Simple implementation
\n\n# Code\n\n/**\n * @param {Function} fn\n * @param {Array} args\n * @param {number} t\n * @return {Function}\n */\nvar cancellable = function(fn, args, t) {\
\n\n# Code\n```\n/**\n * @param {Function} fn\n * @param {Array} args\n * @param {number} t\n * @return {Function}\n */\nvar cancellable = function(fn, args, t) {\n  var timeoutId = setTimeout(function() {\n    fn.apply(null, args);\n  }, t);\n\n  var cancelFn = function() {\n    clearTimeout(timeoutId);\n  };\n\n  return cancelFn;\n};\n\n\n/**\n *  const result = []\n *\n *  const fn = (x) => x * 5\n *  const args = [2], t = 20, cancelT = 50\n *\n *  const log = (...argsArr) => {\n *      result.push(fn(...argsArr))\n *  }\n *       \n *  const cancel = cancellable(fn, args, t);\n *           \n *  setTimeout(() => {\n *     cancel()\n *     console.log(result) // [{"time":20,"returned":10}]\n *  }, cancelT)\n */\n```
['JavaScript']