0Pricing
Frontend Academy · Lesson

Functions: declarations expressions arrow functions

Define functions three ways, understand hoisting, use parameters and return values, and write concise arrow functions.

What Are Functions?

Functions are reusable blocks of code. They take inputs (parameters), execute logic, and optionally return an output. Functions are first-class values in JavaScript — they can be assigned to variables, passed as arguments, and returned from other functions.

Function Declarations

A function declaration creates a named function using the function keyword. Declarations are hoisted — you can call them before they appear in the code.

function greet(name) {
  return `Hello, ${name}!`;
}

// Can call before declaration due to hoisting:
console.log(greet('Alice')); // 'Hello, Alice!'

All lessons in this course

  1. Variables: let const var and Scope
  2. Data Types: string number boolean null undefined
  3. Functions: declarations expressions arrow functions
  4. Control Flow: if else switch for while
← Back to Frontend Academy