Skip to content

Chapter 4 of 33

Operators

Apply arithmetic, comparison, logical, nullish, optional, and bitwise operators.

32 minutes 10 quick checksBy Subha Prasad
Lesson 4 of 33Course navigation

Lesson content

Read, practise, then check your understanding

Arithmetic uses + - * / % **; + also concatenates strings. Prefer strict === and !== because loose equality applies complex coercion. Relational comparison can also coerce operands.

Safe defaults and access

const displayName = user?.profile?.name ?? "Anonymous";
const canEdit = authenticated && role === "editor";
const remainder = 17 % 5;

&& and || return operand values and short-circuit. ?? falls back only for null/undefined, preserving 0, false, and empty string. Optional chaining stops on a nullish base. Bitwise operators convert ordinary numbers to 32-bit integers; use BigInt operators for intentional large-integer bit work. Parenthesize mixed expressions for communication, not merely precedence.

Knowledge check

Answer every question correctly to complete this chapter.

Which statement best describes strict equality?
Which JavaScript term matches this description: Comparison with === that performs no coercive type conversion.
Which statement best describes nullish coalescing?
Which JavaScript term matches this description: The ?? operator selecting a fallback only for null or undefined.
Which statement best describes optional chaining?
Which JavaScript term matches this description: The ?. operator safely stopping a property/call chain for a nullish base.
Which statement best describes short-circuiting?
Which JavaScript term matches this description: Skipping a logical operand when the result is already determined.
Which statement best describes bitwise operation?
Which JavaScript term matches this description: An operation that generally converts Number operands to signed 32-bit integers.

0 of 10 checks passed

Your progress is saved on this device.

Operators | JavaScript Lesson | Subha Prasad