JavaScript Statements

Beginner
12 guides
Updated: Nov 2026

About this index

Statements are the instructions that control flow: conditions, loops, declarations, and jumps like return or throw. Open a topic below for a short beginner guide with examples.

Topics

TopicSummary
if...elserun code when a condition is true, use else and else if branches, with clear beginner examples
switchmatch a value against cases, use break, and handle a default branch with beginner examples
forinit, condition, step, loop a known number of times, and avoid off-by-one mistakes
whilerepeat while a condition is true, avoid infinite loops, with beginner examples
do...whilerun the body at least once, then repeat while the condition stays true
for...inloop enumerable property keys of an object, and why arrays usually prefer for...of
for...ofloop iterable values from arrays, strings, Maps, and Sets with clear beginner examples
let / const / varblock scope vs function scope, redeclaration rules, and when to choose const
returnsend a value out of a function, stop the function early, and what happens with no value
break / continueexit a loop early or skip one iteration, with switch break notes
for await...ofloop over async iterables and async generators.
functiondeclare a named function with parameters and return.
function*declare a generator that yields values.
async functiondeclare a function that returns a Promise.
async function*declare an async generator for for await...of.
throwraise an error on purpose, throw Error objects, and catch them with try...catch
try...catchcatch thrown errors and run finally cleanup (lives under Language Concepts).
usingdispose resources with Symbol.dispose.
await usingasync dispose with Symbol.asyncDispose.
debuggerpause when DevTools is attached.
labelname a loop for break/continue.
withlegacy scope extension (avoid).

Frequently Asked Questions

A complete instruction such as if, for, or return. Expressions produce values; statements do work.
Start with if...else and for, then let/const/var, then for...of.

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful