Skip to content

Instantly share code, notes, and snippets.

@twxia
Forked from arccoza/index.js
Created May 10, 2023 21:12
Show Gist options
  • Save twxia/770515eceec3c08f1ea7d783c45f87b6 to your computer and use it in GitHub Desktop.
Save twxia/770515eceec3c08f1ea7d783c45f87b6 to your computer and use it in GitHub Desktop.
JavaScript Callable Object using proxy
'use strict'
class Callable extends Function {
constructor() {
super()
return new Proxy(this, {
apply: (target, thisArg, args) => target._call(...args)
})
}
_call(...args) {
console.log(this, args)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment