Immediate function using JavaScript ES6 arrow functions

d13

Does anyone know how to write an immediate function using ES6 arrow syntax?

Here's the ES3/5 way of doing it:

(function () {
   //...
}());

I've tried the following but get an unexpected token error on the last line.

(() => {
  //...
}());

You can test this here: http://www.es6fiddle.net/hsb8bgu4/

thefourtheye

From the Arrow functions examples,

(() => "foobar")() // returns "foobar" 

So, the function invocation operator should be outside.

(() => {
  //...
})();

Sample: http://www.es6fiddle.net/hsb8s1sj/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

javascript es6 double arrow functions

From Dev

jQuery .each() function with ES6 arrow functions

From Java

Methods in ES6 objects: using arrow functions

From Java

Using _ (underscore) variable with arrow functions in ES6/Typescript

From Dev

React / ES6 - Why calling a function inside another only works with es6 arrow functions?

From Dev

ES6 arrow functions

From Dev

es6 arrow function not recognizing this operator after transpiling to javascript

From Dev

ES6 if in arrow function

From Dev

Compiling ES6 arrow functions to Es5 using Babel.js

From Dev

es6 arrow functions debugger statement

From Dev

Are ES6 arrow functions incompatible with Angular?

From Dev

ES6 arrow functions not working on the prototype?

From Dev

Convert ES6 arrow function to ES5 function JavaScript

From Dev

Function application for curried functions in JavaScript and ES6

From Dev

JavaScript ES6: Test for arrow function, built-in function, regular function?

From Dev

Using ES6 Arrow Functions in Node 0.11 w/ Foo.prototype

From Dev

How to using ES6 Arrow function to realize Immediately-Invoked Function Expression (IIFE))?

From Dev

ES6 arrow function with no parameters

From Dev

ES6 Assign a variable with an arrow function

From Java

ES6 getter/setter with arrow function

From Dev

ES6 arrow / function equivalency

From Dev

Why is `this` not working in an ES6 arrow function?

From Dev

ES6 Arrow function with brackets

From Dev

ES6 Arrow Function unexpected token

From Dev

setTimeout ReactJS with arrow function es6

From Dev

ES6 Arrow Function unexpected token

From Dev

ES6 Assign a variable with an arrow function

From Dev

Es6 Arrow function to normal js

From Dev

How can I Pass a JavaScript ES6 Arrow Function as a Parameter

Related Related

  1. 1

    javascript es6 double arrow functions

  2. 2

    jQuery .each() function with ES6 arrow functions

  3. 3

    Methods in ES6 objects: using arrow functions

  4. 4

    Using _ (underscore) variable with arrow functions in ES6/Typescript

  5. 5

    React / ES6 - Why calling a function inside another only works with es6 arrow functions?

  6. 6

    ES6 arrow functions

  7. 7

    es6 arrow function not recognizing this operator after transpiling to javascript

  8. 8

    ES6 if in arrow function

  9. 9

    Compiling ES6 arrow functions to Es5 using Babel.js

  10. 10

    es6 arrow functions debugger statement

  11. 11

    Are ES6 arrow functions incompatible with Angular?

  12. 12

    ES6 arrow functions not working on the prototype?

  13. 13

    Convert ES6 arrow function to ES5 function JavaScript

  14. 14

    Function application for curried functions in JavaScript and ES6

  15. 15

    JavaScript ES6: Test for arrow function, built-in function, regular function?

  16. 16

    Using ES6 Arrow Functions in Node 0.11 w/ Foo.prototype

  17. 17

    How to using ES6 Arrow function to realize Immediately-Invoked Function Expression (IIFE))?

  18. 18

    ES6 arrow function with no parameters

  19. 19

    ES6 Assign a variable with an arrow function

  20. 20

    ES6 getter/setter with arrow function

  21. 21

    ES6 arrow / function equivalency

  22. 22

    Why is `this` not working in an ES6 arrow function?

  23. 23

    ES6 Arrow function with brackets

  24. 24

    ES6 Arrow Function unexpected token

  25. 25

    setTimeout ReactJS with arrow function es6

  26. 26

    ES6 Arrow Function unexpected token

  27. 27

    ES6 Assign a variable with an arrow function

  28. 28

    Es6 Arrow function to normal js

  29. 29

    How can I Pass a JavaScript ES6 Arrow Function as a Parameter

HotTag

Archive