Last active
August 11, 2023 07:36
-
-
Save arccoza/533a0983cf51a4c2c6114bd49d8feec1 to your computer and use it in GitHub Desktop.
JavaScript Callable Object using callee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
class Callable extends Function { | |
constructor() { | |
super('return arguments.callee._call.apply(arguments.callee, arguments)') | |
// We can't use the rest operator because of the strict mode rules. | |
// But we can use the spread operator instead of apply: | |
// super('return arguments.callee._call(...arguments)') | |
} | |
_call(...args) { | |
console.log(this, args) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Remove
'use strict';
since this does not work in strict mode.