Skip to content

Instantly share code, notes, and snippets.

@tk42
Created August 28, 2022 06:10
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 tk42/800860aa8a3759c01df6ef8ef2ff99cb to your computer and use it in GitHub Desktop.
Save tk42/800860aa8a3759c01df6ef8ef2ff99cb to your computer and use it in GitHub Desktop.
serialize/deserialize function in JS code
function foo(message: string) {
alert(message);
return 'Hello, serialised world!';
}
var storedFunction = foo.toString();
var actualFunction = new Function('return ' + foo.toString())()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment