1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 01:36:57 +02:00
LeetCode/js/call-function-with-custom-context.js

14 lines
293 B
JavaScript
Raw Normal View History

/**
* @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
*/