Agenda

Named Functions

Anonymous Functions

Function Declarations

Arrow Functions

Callbacks

Overview of Functions

In some languages, they might call them “methods”. In JavaScript, they’re called “functions”. But they’re usually the same thing: A block of re-usable code that has an identifier. The logic of how they work is mostly the same, but how we code them is significantly different.

You already know how to use functions that are part of the language: so far you’ve learned alert(), confirm(), prompt(), typeof(), Number(), Boolean(), String(), and probably others in your explorations.

You can also create functions, of course — similar to how you would create function in Python.

There are different kinds of functions:

There are different techniques we can use to create functions:

When creating functions, it’s also important to understand the visibility of variables, parameters, and the functions themselves (scope).