Skip to content

Instantly share code, notes, and snippets.

@arccoza
Last active August 11, 2023 07:36
Show Gist options
  • Save arccoza/533a0983cf51a4c2c6114bd49d8feec1 to your computer and use it in GitHub Desktop.
Save arccoza/533a0983cf51a4c2c6114bd49d8feec1 to your computer and use it in GitHub Desktop.
JavaScript Callable Object using callee
'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)
}
}
@nickshanks
Copy link

Remove 'use strict'; since this does not work in strict mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment