Created
November 30, 2012 17:49
-
-
Save raultm/4177339 to your computer and use it in GitHub Desktop.
Self-Invoked Anonymous Function
This file contains 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
(function(msg){ | |
console.log(msg); | |
})("42"); |
This file contains 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
var print = function(msg){ | |
console.log(msg); | |
}; | |
print("42"); | |
//output: 42 | |
(print)("42"); | |
//output: 42 | |
(function(msg){ | |
console.log(msg); | |
})("42"); | |
//output: 42 |
This file contains 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
function(msg){ | |
console.log(msg); | |
}("42"); | |
// output: Uncaught SyntaxError: Unexpected token ( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment