Skip to content

Instantly share code, notes, and snippets.

@skyitachi
Forked from myshov/function_invocation.js
Created June 19, 2017 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyitachi/2c0c078d1f6defb7fd5b4b74eb9d8562 to your computer and use it in GitHub Desktop.
Save skyitachi/2c0c078d1f6defb7fd5b4b74eb9d8562 to your computer and use it in GitHub Desktop.
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);
new (require('vm').Script)('console.log(11)').runInThisContext();
@skyitachi
Copy link
Author

just memo

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