Declarations vs Expressions, Arrow Basics
Function declarations vs expressions, arrow function syntax, and simple usage patterns.
Declarations vs Expressions, Arrow Basics is a free JavaScript Academy lesson on CoddyKit — lesson 1 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the JavaScript Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Intro
Goal: Tell function declarations from expressions, learn basic arrow syntax, and pick the simplest form for the job.
- Declaration
- Expression
- Arrow basics

Function declaration
A function declaration is hoisted, so calls may appear above the definition.
// Function declaration
// Can be called before or after its definition (hoisted)
console.log(greet("Ayla"));
function greet(name) {
return "Hello, " + name + "!";
}
console.log(greet("Coder"));

Function expression
A function expression is created at runtime; call it after the assignment line.
// Function expression
// Assigned to a variable; not callable before this line
const add = function (a, b) {
return a + b;
};
console.log("Sum:", add(2, 3));

Arrow basics
Arrow functions are concise. For a single parameter you can omit parentheses; one-line bodies can omit return.
// Arrow function basics
// Short, expression-friendly syntax
const double = (n) => {
return n * 2;
};
const square = n => n * 2; // simple one-liner for demo
console.log(double(4));
console.log(square(4));

Choosing a form
Use declarations for named utilities; use arrows for tiny inline helpers.
// Pick the simplest form for clarity
// Use declarations for top-level named utilities
function toTitle(name) {
return "Title: " + name;
}
// Use arrows for tiny inline helpers
const shout = text => text.toUpperCase();
console.log(toTitle("Intro"));
console.log(shout("hello"));

Tips for beginners
Tips:
- Name functions for what they do.
- One small task per function.
- Prefer short, flat bodies and clear returns.

Hoisting quiz
Quick check: Hoisting behavior.

Recap
Recap: Declarations are hoisted and good for named utilities; expressions/arrows are created at runtime and great for small helpers.

Frequently asked questions
Is the “Declarations vs Expressions, Arrow Basics” lesson free?
Yes — the full text of “Declarations vs Expressions, Arrow Basics” is free to read here on the web, and the JavaScript Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the JavaScript Academy course, upgrade to CoddyKit PRO.
What will I learn in “Declarations vs Expressions, Arrow Basics”?
Function declarations vs expressions, arrow function syntax, and simple usage patterns. You practise JavaScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start JavaScript Academy?
No prior experience is required. JavaScript Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 3, so you can start here or from the beginning and move at your own pace.
How long does the “Declarations vs Expressions, Arrow Basics” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this JavaScript Academy lesson?
Yes. Every JavaScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Declarations vs Expressions, Arrow Basics
- Parameters, Defaults, Rest, and Returns
- this Basics; call/apply/bind (intro)