Last active
August 29, 2015 14:11
-
-
Save fmtarif/b8a1e8cd1824ef63bf26 to your computer and use it in GitHub Desktop.
#js self executing anonymous function explained
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title></title> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
| </head> | |
| <body> | |
| <script> | |
| /* | |
| function test_alert(foo) { | |
| alert(foo); | |
| } | |
| // test_alert('bar'); //usual | |
| (test_alert)('bar'); //Since functions in Javascript are objects like any other, | |
| //we can use operators on the object such as the ( and ) grouping operators. | |
| */ | |
| (function(foo){ | |
| alert(foo); | |
| })('bar'); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment