Skip to content
Learn Netverks

Lesson

Step 15/36 42% through track

functions-declarations

Function declarations

Last reviewed May 28, 2026 Content v20260528
Track mode
client_javascript
Means
In-browser JS
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Function declarations—the ideas, syntax, and habits you need before moving on in JavaScript.

Without a solid grasp of Function declarations, you will repeat mistakes in JavaScript exercises and on real pages or scripts.

You will apply Function declarations in contexts like: Browsers, Node.js services, edge workers, and tooling ecosystems (bundlers, test runners).

Run JavaScript in the in-browser sandbox, use the terminal output panel, and verify with MCQs.

When the previous lesson's MCQs feel easy and you can explain Function declarations in your own words.

Functions package reusable logic. Declarations are hoisted; expressions assign functions to variables.

Forms

  • Declaration: function add(a, b) { return a + b; }
  • Expression: const add = function(a, b) { ... }
  • Parameters default: function greet(name = 'guest')

Pure functions

Same inputs → same outputs, no side effects—easier to test and reason about.

Important interview questions and answers

  1. Q: Hoisting?
    A: Declarations available before line in scope—expressions not until assigned.
  2. Q: Return undefined?
    A: Functions without return yield undefined.

Self-check

  1. Difference declaration vs expression?
  2. What is a side effect?

Tip: Re-run the playground code for functions-declarations and tweak one line before the MCQs.

Interview prep

Hoisting?

Declarations available throughout their scope.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What would you log to verify this behavior?
  • What breaks if you run this before the DOM is ready?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump