From the Arrow functions examples,
(() => "foobar")() // returns "foobar"
So, the function invocation operator should be outside.
(() => {
//...
})();
Sample: http://www.es6fiddle.net/hsb8s1sj/
Related Contents:
- JavaScript ES6: Test for arrow function, built-in function, regular function?
- When should I use arrow functions in ECMAScript 6?
- Are ‘Arrow Functions’ and ‘Functions’ equivalent / interchangeable?
- What’s the meaning of “=>” (an arrow formed from equals & greater than) in JavaScript?
- Methods in ES6 objects: using arrow functions
- When should I use a return statement in ES6 arrow functions
- ECMAScript 6 arrow function that returns an object
- One-liner to take some properties from object in ES 6
- What does “this” refer to in arrow functions in ES6?
- What do multiple arrow functions mean in JavaScript?
- Arrow Functions and This [duplicate]
- Why doesn’t my arrow function return a value?
- Using jQuery $(this) with ES6 Arrow Functions (lexical this binding)
- Can you bind ‘this’ in an arrow function?
- Arrow function without curly braces
- How does this object method definition work without the “function” keyword?
- Curly Brackets in Arrow Functions
- Why shouldn’t JSX props use arrow functions or bind?
- ES6 destructuring function parameter – naming root object
- How do I write a named arrow function in ES2015?
- What are the differences (if any) between ES6 arrow functions and functions bound with Function.prototype.bind?
- Official information on `arguments` in ES6 Arrow functions?
- What is the motivation for bringing Symbols to ES6?
- How to extend Function with ES6 classes?
- Using _ (underscore) variable with arrow functions in ES6/Typescript
- What is “function*” in JavaScript?
- ES6 arrow functions not working on the prototype?
- Arrow Function in Object Literal [duplicate]
- What does arrow function ‘() => {}’ mean in Javascript? [duplicate]
- Proper use of const for defining functions
- How can I clone a JavaScript object except for one key?
- Is there a mechanism to loop x times in ES6 (ECMAScript 6) without mutable variables?
- Can I use arrow function in constructor of a react component?
- Can I use ES6’s arrow function syntax with generators? (arrow notation)
- ESCMAScript 6 arrow functions – parentheses around parameter
- Function parameter definitions in ES6
- Find all values by specific key in a deep nested object
- user defined object equality for a set in harmony (es6)
- How can I differentiate between an arrow function, class and a normal function?
- Why is `throw` invalid in an ES6 arrow function?
- Is it possible to reset an ECMAScript 6 generator to its initial state?
- Square Brackets Javascript Object Key
- Keyword ‘const’ does not make the value immutable. What does it mean?
- What does three dots do in ReactJS [duplicate]
- Using Array objects as key for ES6 Map
- Chrome console already declared variables throw undefined reference errors for let
- Importing modules using ES6 syntax and dynamic path [duplicate]
- ES6 deep nested object destructuring
- Get values from an object in JavaScript [duplicate]
- Remove empty & null values from nested object (ES6) – Clean nested Objects