Created
August 1, 2017 11:24
-
-
Save jineeshjohn/6740ba204a032bcc562d481782f79604 to your computer and use it in GitHub Desktop.
Different ways to write functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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