Created
April 30, 2015 15:58
-
-
Save guillermoroblesjr/0e7881125ac74d0e573f to your computer and use it in GitHub Desktop.
Create a JavaScript function dynamically with strings
This file contains hidden or 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
| // Create the function | |
| // 'a' and 'b' are the arguments available to the function, | |
| // the last string is the body of your new function | |
| var x = Function('a','b','console.log(a+b); return "apples";'); | |
| // Implementation | |
| x(1,2); // will return 'apples' and will log to the console '3'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment