In frontend development, there are several terms that may be unfamiliar to you. This glossary provides explanations of these terms to help you better understand JavaScript and frontend development concepts. Let’s dive in!

Terms

Asynchronous

Asynchronous code allows you to initiate a task, forget about it, and receive the result when it’s ready, without having to wait for it. An example is an AJAX call, where you can continue with other tasks while waiting for the response. Promises and async/await are modern ways to handle asynchronous operations.

Block

In JavaScript, a block refers to code enclosed within curly braces ({}). For example, an if statement or a for loop contains a block of code.

Block Scoping

Block scoping, also known as block-level scoping, refers to the visibility and accessibility of variables defined within a block. Variables defined inside a block are only accessible within that block and not outside of it.

Callback

A callback is a function that is invoked when a particular event or action occurs. For example, a callback function is used when handling a click event on an element or when a fetch request is completed.

Declarative

A declarative approach allows you to specify what you want to accomplish, leaving the implementation details to the underlying system. React, for example, is considered declarative, as it allows you to reason about abstractions rather than directly manipulating the DOM. Higher-level programming languages tend to be more declarative compared to lower-level languages like Assembly. HTML itself is also declarative.

Fallback

A fallback is a backup or alternative solution that is used when a particular functionality is not available or cannot be accessed. For example, if a user has JavaScript disabled, a fallback can be provided in the form of a plain HTML version of the page. Fallbacks are important to ensure a smooth experience for users in different scenarios.

Function Scoping

Function scoping refers to the visibility and accessibility of variables defined within a function. Variables defined inside a function are only accessible within that function.

Immutability

In programming, immutability refers to the property of a variable or data structure that prevents its value from being modified after it is assigned. Immutable variables cannot be changed, while mutable variables can be modified. The concept of immutability also applies to objects and arrays.

Lexical Scoping

Lexical scoping, also known as static scoping, determines the value of a variable based on its position in the source code, rather than its position during runtime. JavaScript adopts lexical scoping, which means the scope of a variable is determined by the structure of the code.

Polyfill

A polyfill is a piece of code that provides new functionality or API available in modern JavaScript or modern browsers to older browsers that do not support them. It allows developers to use new features while maintaining compatibility with older browsers. A polyfill is a specific type of shim.

Pure Function

A pure function is a function that produces the same output for the same input and does not have any side effects. It does not modify external resources or rely on external state. The output of a pure function solely depends on its input, making it predictable and testable.

Reassignment

In JavaScript, variables declared with var or let can be reassigned multiple times. However, variables declared with const cannot be reassigned. While const variables are immutable, objects declared with const can still be modified through their methods.

Scope

Scope refers to the context in which a variable is defined and can be accessed. JavaScript has different scopes depending on how variables are declared. Variables declared with let and const have block scope, meaning they are only accessible within the block they are defined in. Variables declared with var have function scope, allowing them to be accessed within the entire function.

Scoping

Scoping is the process by which a programming language determines the scope of variables and functions. Different scoping mechanisms exist, including block scoping, function scoping, and lexical scoping.

Shim

A shim, also known as a polyfill, is a small piece of code that provides compatibility for new functionality or APIs in older browsers or environments. It acts as a compatibility layer, allowing developers to use features that are not natively supported.

Side Effect

A side effect occurs when a function interacts with external resources or modifies something outside of its own scope. Examples of side effects include network requests, file system operations, or changes to the user interface. Pure functions do not have side effects.

State

In the context of components, state refers to the data that a component manages. A stateful component, function, or class has its own state and can store and manage data, such as arrays or counters.

Stateful

A stateful component, function, or class manages its own state and can store and modify data as needed. It holds information that can change over time, allowing the component to respond to user interactions or updates from external sources.

Stateless

A stateless component, function, or class, also known as a “dumb” component, does not have its own state. Its output or presentation is solely determined by its input arguments and does not rely on internal data. Pure functions are considered stateless. In React, stateless components are now referred to as function components, as hooks allow them to use state.

Strict Mode

Strict mode is a feature introduced in ECMAScript 5.1 that enables a stricter set of rules for JavaScript execution. It helps identify and prevent common programming mistakes, such as using undeclared variables, and enforces best practices. It is recommended to use strict mode to improve code quality and avoid potential issues.

Tree Shaking

Tree shaking is the process of removing unused or unreachable code from the bundled JavaScript file. It helps reduce the file size and improve loading time by eliminating dead code, i.e., code that is not used or referenced by the application.

Conclusion

This glossary provides an overview of some key terms used in JavaScript and frontend development. Understanding these terms will help you navigate and communicate effectively in the world of frontend development. Keep exploring and expanding your knowledge to become a proficient developer!