Skip to content

Chapter 2 of 33

Basic Syntax and Structure

Understand statements, expressions, blocks, comments, strict mode, and modules.

26 minutes 10 quick checksBy Subha Prasad
Lesson 2 of 33Course navigation

Lesson content

Read, practise, then check your understanding

JavaScript is case-sensitive. Expressions produce values; statements control execution. Braces group blocks and lexical scope. Semicolons are sometimes inserted automatically, but consistent explicit formatting avoids surprising boundaries.

A small module

"use strict";

function square(value) {
  return value * value;
}

const input = 7;
console.log(square(input));

Use //, /* */, and documentation conventions deliberately. Modules are strict automatically and isolate top-level bindings. Identifiers support Unicode but readable project conventions matter more. Prefer small files with explicit imports/exports and format automatically. Read the first syntax or runtime error first, because later failures often cascade from it.

Knowledge check

Answer every question correctly to complete this chapter.

Which statement best describes statement?
Which JavaScript term matches this description: A complete instruction such as a declaration or return.
Which statement best describes expression?
Which JavaScript term matches this description: Code that evaluates to a value.
Which statement best describes block?
Which JavaScript term matches this description: A brace-delimited group of statements that may create scope.
Which statement best describes strict mode?
Which JavaScript term matches this description: A language mode that rejects selected error-prone legacy behavior.
Which statement best describes module?
Which JavaScript term matches this description: A file with its own scope that may import and export bindings.

0 of 10 checks passed

Your progress is saved on this device.

Basic Syntax and Structure | JavaScript Lesson | Subha Prasad