JavaScript_

The universal language of the web. Core syntax, ES6+ features, and modern asynchronous patterns.

Getting Started

JavaScript is a lightweight, interpreted, just-in-time compiled programming language with first-class functions. While primarily known as the scripting language for Web pages, it is heavily used in non-browser environments like Node.js.

Variables & Declarations

Modern JavaScript relies strictly on block-scoped declarations to prevent memory leaks and unintended global mutations.

Strings & Interpolation

Template literals (backticks) provide a clean syntax for multi-line strings and dynamic expression interpolation, replacing legacy string concatenation.

The Console

The global console object provides access to the browser's debugging console.


Conditionals & Logic

Strict Equality

Always use strict equality (===) to prevent JavaScript's engine from performing implicit type coercion, which can lead to unpredictable bugs.

Modern Logical Operators

JavaScript provides elegant operators for handling fallback values and deeply nested object properties without throwing undefined errors.

Ternary Operator

The ternary operator is a concise, inline alternative to if-else blocks, highly useful in variable assignments and React JSX.


Functions

Function Declarations vs. Arrow Functions

Arrow functions (=>) provide a concise syntax and, crucially, do not bind their own this context. They inherit this from the enclosing lexical scope.


Scope & Closures

Scope dictates the visibility of variables. var is scoped to the nearest function block, whereas let and const are scoped to the nearest enclosing block ({}).


Arrays & Sets

Array Mutation

Arrays in JavaScript are dynamic. Be mindful of which methods mutate the original array versus those that return a new array.

Sets

Sets are collections of uniquely structured values. They are highly optimized for checking value existence (has).


Loops & Iterators

Declarative Iteration (Array Methods)

Prefer array iterator methods (map, filter, reduce) over standard for loops for functional, non-mutating data transformations.

Iterating Objects and Iterables


Objects & Classes

Object Composition & Destructuring

Objects are key-value dictionaries. Destructuring allows you to cleanly extract properties into standalone variables.

ES6 Classes

Classes are syntactic sugar over JavaScript's prototype-based inheritance, providing a cleaner, object-oriented pattern.


Modules

JavaScript relies on the ES Module (ESM) system to split code into reusable files.


Asynchronous JavaScript

Promises

Promises represent the eventual completion (or failure) of an asynchronous operation, preventing the "callback hell" of older nested architectures.

Async / Await

Introduced in ES2017, async/await is syntactic sugar over Promises, allowing asynchronous code to be written and read like synchronous, top-down code.


Network Requests

The Fetch API

The modern standard for making HTTP requests natively in the browser, replacing the legacy XMLHttpRequest API.