LeetCode/js/call-function-with-custom-context.js
Matej Focko 2351dfd0ee
chore: unwrap one layer
Signed-off-by: Matej Focko <mfocko@redhat.com>
2023-12-12 14:36:00 +01:00

13 lines
293 B
JavaScript

/**
* @param {Object} context
* @param {any[]} args
* @return {any}
*/
Function.prototype.callPolyfill = function(context, ...args) {
return this.apply(context, args);
};
/**
* function increment() { this.count++; return this.count; }
* increment.callPolyfill({count: 1}); // 2
*/