Skip to content

Instantly share code, notes, and snippets.

@jineeshjohn
Created August 1, 2017 11:24
Show Gist options
  • Save jineeshjohn/6740ba204a032bcc562d481782f79604 to your computer and use it in GitHub Desktop.
Save jineeshjohn/6740ba204a032bcc562d481782f79604 to your computer and use it in GitHub Desktop.
Different ways to write functions
function A(){}; // function declaration
var B = function(){}; // function expression
var C = (function(){}); // function expression with grouping operators
var D = function foo(){}; // named function expression
var E = (function(){ // IIFE that returns a function
return function(){}
})();
var F = new Function(); // Function constructor
var G = new function(){}; // special case: object constructor
var H = x => x * 2; // ES6 arrow function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment