Why do you need to invoke an anonymous function on the same line?

Drop the semicolon after the function definition. (function (msg){alert(msg)}) (‘SO’); Above should work. DEMO Page: https://jsfiddle.net/e7ooeq6m/ I have discussed this kind of pattern in this post: jQuery and $ questions EDIT: If you look at ECMA script specification, there are 3 ways you can define a function. (Page 98, Section 13 Function Definition) 1. Using … Read more

Explain the encapsulated anonymous function syntax

It doesn’t work because it is being parsed as a FunctionDeclaration, and the name identifier of function declarations is mandatory. When you surround it with parentheses it is evaluated as a FunctionExpression, and function expressions can be named or not. The grammar of a FunctionDeclaration looks like this: function Identifier ( FormalParameterListopt ) { FunctionBody … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)