else — the alternative branch of an if statement
The `else` keyword introduces the branch executed when the associated `if` condition converts to `false`. It is optional and cannot appear on its own.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
The `else` keyword introduces the branch executed when the associated `if` condition converts to `false`. It is optional and cannot appear on its own.
The export keyword exposes elements of an ECMAScript module to other modules. It supports named exports, one default export, and re-exporting from another module.
The `extends` keyword creates a derived class. When given a base constructor, it links the class to it through prototype chains. This lets the class inherit and override methods, and `super` lets it call the base constructor or inherited methods.
The finally keyword introduces a block executed after try and any catch, before control continues elsewhere. It supports cleanup even during a return or exception, but can itself override the earlier outcome.
The for keyword creates a loop. Its classic form combines initialization, a condition checked before each iteration, and an update performed after the loop body.
The function keyword defines a function with parameters and a body. Learn the difference between a declaration and a function expression, and how return supplies a result.
The get syntax defines a getter: a function invoked when a property is read. It lets you compute a value without calling a method with parentheses; get itself is not a reserved word.
The if statement selects a code branch based on a condition. An optional else handles a false result, while else if checks further conditions in a defined order.
The import keyword makes exports from other modules available. Learn static declarations, live bindings, and how import(...), import.meta, and ordinary function calls differ.
let declares a block-scoped variable that can be reassigned. Learn initialization, shadowing, and the temporal dead zone, plus the differences from var and const.
The new operator invokes a constructor with supplied arguments and returns an object. For an ordinary constructor function, it creates an object linked to the function's prototype and exposes that object inside the function as this.
`of` separates the loop variable from the source of values in `for...of`. It is a contextual keyword, not a reserved word: outside that role, it can be used as a variable name.
The return statement ends function execution and can send a result back to the caller. Learn about an empty return, early exits, and the newline pitfall.
`set` defines a setter: a function invoked when a property is assigned. It is part of accessor syntax, not a word reserved in every context.
`static` defines fields, methods, and accessors belonging to the class itself rather than its instances. A `static { ... }` block performs initialization when the class is created, without calling `new`.
The super keyword calls a base constructor or accesses properties through the prototype of the object where a method was defined. A super.method() call preserves the current this value.
The switch statement selects where execution begins by strictly comparing a value with case expressions. Learn how default, break, fall-through, and the shared declaration scope affect control flow.
The `this` keyword reads the current `this` binding. In an ordinary function its value depends on how the function is called, while an arrow function uses the enclosing binding. Storing a function in an object does not permanently bind it to that object.
The throw statement raises an exception and interrupts normal execution. A catch clause can receive the thrown value; no line break is allowed between throw and its expression.
The try statement defines a block whose exceptions can be handled by catch. An optional finally runs finalization code even during return or exception propagation. A catch, finally, or both is required.
The `var` keyword declares a variable whose scope is not limited by an ordinary block. A new binding usually starts with `undefined`, but a separate binding in a function body can instead start with the value of a same-named parameter. A declaration without an initializer leaves an existing binding’s value unchanged. An initializer assigns a value only when execution reaches the declaration.
The while statement repeats its body while its condition converts to true. It checks the condition before every iteration, so the body might never run.
The with statement temporarily includes an object in name lookup. It is forbidden in strict mode; use explicit property access in new code.
The `yield` expression suspends a generator and exposes a value to its consumer. A subsequent `next(value)` resumes execution and supplies a value to the suspended expression; `yield*` delegates iteration.