Peter Michaux discusses the difference in An Important Pair of Parens.
Basically the parentheses are a convention to denote that an immediately invoked function expression is following, not a plain function. Especially if the function body is lengthy, this reduces surprises,
More Related Contents:
- What does "use strict" do in JavaScript, and what is the reasoning behind it?
- var functionName = function() {} vs function functionName() {}
- What’s the meaning of “=>” (an arrow formed from equals & greater than) in JavaScript?
- Add a property to a JavaScript object using a variable as the name?
- Explain the encapsulated anonymous function syntax
- Question mark and colon in JavaScript
- Where can I get info on the object parameter syntax for JavaScript functions?
- Why can’t I access a property of an integer with a single dot?
- What does “options = options || {}” mean in Javascript? [duplicate]
- Why do results vary based on curly brace placement?
- How can I refer to a variable using a string containing its name?
- Why should I use a semicolon after every function in javascript?
- Difference between using bracket (`[]`) and dot (`.`) notation [duplicate]
- What is the correct syntax of ng-include?
- javascript function leading bang ! syntax
- Double quotes within php script echo
- No semicolon before [] is causing error in JavaScript
- Can I use ES6’s arrow function syntax with generators? (arrow notation)
- Why does 10..toString() work, but 10.toString() does not? [duplicate]
- How do I remove javascript validation from my eclipse project?
- How to convert Set to Array?
- syntax error: unexpected token
- How to find Javascript syntax errors? [closed]
- Nested JSON objects – do I have to use arrays for everything?
- JavaScript instance functions versus prototype functions [duplicate]
- JSON syntax for property names
- When is the ‘javascript:’ prefix valid syntax?
- Does assignment with a comma work?
- Javascript history.PushState not working?
- + operator before expression in javascript: what does it do?