Created
May 13, 2015 21:03
-
-
Save AlbertoMonteiro/bb6c1d61a72a8ff5c158 to your computer and use it in GitHub Desktop.
C# Lambda in Javascript
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
| String.prototype.toFunc = function() { | |
| var parts = this.split("=>"); | |
| var args = parts[0]; | |
| var body = parts[1]; | |
| var argsList = args.replace(/[()]/gi, "").split(","); | |
| return new Function(argsList, "return " + body) | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment