Skip to content

Instantly share code, notes, and snippets.

@jdberrocal1
Last active January 18, 2018 18:19
Show Gist options
  • Select an option

  • Save jdberrocal1/f54a1076ba97e30c9014d7ac20f00ed3 to your computer and use it in GitHub Desktop.

Select an option

Save jdberrocal1/f54a1076ba97e30c9014d7ac20f00ed3 to your computer and use it in GitHub Desktop.
JavaScript Function Definitions
1. Named Function Declaration:
function test () {
// code
}
2. Anonymous Function Declaration (Usually callbacks)
array.forEach(function (item){})
3. Named Function Expression
var x = function test (a, b) {return a * b};
4. Anonymous Function Expression
var x = function (a, b) {return a * b};
5. Immediately Invoked Function Expression (IIFE)
(function () {
var x = "Hello!!";
})();
6. Arrow Functions (ES6)
array.forEach(item => {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment