Team,
I received syntax error when using function(){}
, but not when (function(){})
, why?
I know (function(){})
is still declaration '(function(){})()
' is the expression.
But why this declaration is not possible with simply function(){}
without covering with (... )
?
<html>
<body>
<script>
function(){} //**Syntax error**
(function(){}) //Declaration
(function(){})() //Expression; so executed.
</script>
</body>
</html>