Skip to content

Instantly share code, notes, and snippets.

@raultm
Created November 30, 2012 17:49
Show Gist options
  • Save raultm/4177339 to your computer and use it in GitHub Desktop.
Save raultm/4177339 to your computer and use it in GitHub Desktop.
Self-Invoked Anonymous Function
(function(msg){
console.log(msg);
})("42");
var print = function(msg){
console.log(msg);
};
print("42");
//output: 42
(print)("42");
//output: 42
(function(msg){
console.log(msg);
})("42");
//output: 42
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