mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-09 15:59:06 +01:00
problems(js): add “2693. Call Function with Custom Context”
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
85b9b28037
commit
8a7ffff7d2
1 changed files with 13 additions and 0 deletions
13
problems/js/call-function-with-custom-context.js
Normal file
13
problems/js/call-function-with-custom-context.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* @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
|
||||
*/
|
Loading…
Reference in a new issue