DEV Community

Cover image for JavaScript Essential Terms Every Developer Must Know
Mainul Hasan
Mainul Hasan

Posted on • Originally published at webdevstory.com

JavaScript Essential Terms Every Developer Must Know

In today’s web development, JavaScript is not just an advantage but a necessity. JavaScript continuously brings new features, terms and concepts that make web applications more interactive, efficient, and user-friendly.

Whether you’re just starting your journey in web development or looking to brush up on your skills, mastering the essential terms of JavaScript is crucial.

In this comprehensive guide, we’ll explore JavaScript key concepts, from basic to advanced, that every developer should know.

We cover the fundamental DOM to the asynchronous magic of Promises and the modern capabilities of Service Workers which will help you to deepen your understanding key terms of JavaScript.

Get ready to get the most out of web development by learning the key terms that make up the JavaScript world.

1 — Payload in JavaScript

In JavaScript, especially when dealing with web development and APIs, the term payload refers to the actual data sent over in a request or received in a response.

Payloads can be in various formats, with JSON being one of the most common because of its lightweight and easy-to-parse structure.

Why is Payload Important?

  • Data Exchange: Payloads are the crux of data exchange between clients and servers. Understanding how to handle payloads is essential for implementing API calls, Ajax requests, and any form of data retrieval or submission.

  • Efficiency: Knowing how to structure and parse payloads efficiently can significantly impact the performance of web applications.



// Sending a JSON payload to a server
fetch('https://api.example.com/data', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({
            key: 'value'
        }),
    })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch((error) => console.error('Error:', error));


Enter fullscreen mode Exit fullscreen mode

2 — Understanding ReadableStream in JavaScript

ReadableStream is a part of the Streams API, which provides a way to handle streaming data in JavaScript.

Streams are objects that let you read data from a source or write data to a destination continuously.

In simpler terms, streams offer a way to process data piece by piece as it arrives, which can be more efficient than loading entire chunks of data into memory.

Applications of ReadableStream

  • Fetching Large Resources: Ideal for scenarios where you’re dealing with large datasets or files, allowing you to process data as soon as the first chunk is available, rather than waiting for the entire resource to download.

  • Real-time Data: Useful for applications that require real-time data processing, such as live audio or video streaming.



// Assuming fetch API supports streams
fetch('path/to/text-file.txt')
    .then(response => {
        const reader = response.body.getReader();
        return new ReadableStream({
            start(controller) {
                function push() {
                    reader.read().then(({
                        done,
                        value
                    }) => {
                        if (done) {
                            controller.close();
                            return;
                        }
                        controller.enqueue(value);
                        push();
                    });
                }
                push();
            }
        });
    })
    .then(stream => new Response(stream))
    .then(response => response.text())
    .then(text => console.log(text))
    .catch(err => console.error(err));


Enter fullscreen mode Exit fullscreen mode

3 — Module Systems

JavaScript’s module systems, such as CommonJS and ES Modules, revolutionize how developers organize and reuse code.

By dividing code into manageable modules, these systems enhance code maintainability, readability, and scalability, making it simpler to build complex applications.



  // ES Modules example
  import {
      fetchData
  } from './api.js';

  fetchData().then(data => console.log(data));


Enter fullscreen mode Exit fullscreen mode

4 — DOM (Document Object Model)

The DOM is a programming interface for web documents. It represents the page so that programs can change the document structure, style, and content.

The DOM represents the document as nodes and objects; that way, programming languages can interact with the page.

Understanding the DOM is crucial for manipulating web pages, including adding, removing, or modifying elements and content dynamically.



// Accessing an element and changing its text content
  document.getElementById('demo').textContent = 'Hello, World!';


Enter fullscreen mode Exit fullscreen mode

Dive into ‘Meta Programming with JavaScript’ on Coursera, a course designed for beginners to advance their skills. Taught by Meta staff, this flexible, multi-language course boasts a high satisfaction rate and is open for enrollment.

5 — Event

Events are actions or occurrences that happen in the system you are programming, which the system tells you about so you can respond to them in some way if desired.

For example, events could be user interactions like clicking, and typing, or system occurrences such as the loading of resources.

Handling events is fundamental to creating interactive web applications, allowing developers to execute code in response to user actions.



document.getElementById('myButton').addEventListener('click', function() {
    alert('Button clicked!');
});


Enter fullscreen mode Exit fullscreen mode

6 — Event Delegation

Event delegation leverages the concept of event bubbling to add a single event listener to a parent element instead of multiple listeners to individual child elements.

This strategy optimizes performance and memory usage, especially in dynamic applications with many interactive elements.



document.getElementById('parent').addEventListener('click', (event) => {
    if (event.target.tagName === 'LI') {
        console.log('List item clicked!');
    }
});


Enter fullscreen mode Exit fullscreen mode

7 — Content Security Policy (CSP)

A Content Security Policy (CSP) is a security standard designed to prevent cross-site scripting (XSS), clickjacking, and other code injection attacks.

By specifying allowed sources for scripts, styles, and other resources, CSP helps developers secure their web applications against malicious activities.

8 — Progressive Enhancement & Graceful Degradation

Progressive enhancement and graceful degradation are design strategies aimed at ensuring web applications are accessible to the widest potential audience.

It focuses on building a functional core experience first, then adding enhancements, while graceful degradation starts with a full experience and ensures it remains usable on older platforms.

9 — JSON A Widely Used JavaScript Terms

JSON is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate.

It is based on a subset of JavaScript but is language-independent, with parsers available for virtually every programming language.

JSON plays a crucial role in modern web development, especially in APIs, as developers use it to structure data sent between clients and servers.



// JavaScript object
const obj = {
    name: "John",
    age: 30,
    city: "New York"
};

// Converting JavaScript object to JSON
const myJSON = JSON.stringify(obj);
console.log(myJSON); // {"name":"John","age":30,"city":"New York"}

// Parsing JSON to JavaScript object
const myObj = JSON.parse(myJSON);
console.log(myObj.name); // John


Enter fullscreen mode Exit fullscreen mode

10 — AJAX (Asynchronous JavaScript and XML)

AJAX is a set of web development techniques that allows web applications to send and retrieve data from a server asynchronously, without interfering with the display and behavior of the existing page.

It lets you make fast, dynamic web pages. This means that you can change parts of a page without having to reload the whole thing, which makes the user experience better.



// Basic AJAX call using XMLHttpRequest
const xhr = new XMLHttpRequest();

xhr.open('GET', 'https://api.example.com/data', true);

xhr.onload = function() {
    if (xhr.status >= 200 && xhr.status < 300) {
        console.log('Success:', JSON.parse(xhr.responseText));
    } else {
        console.error('Error:', xhr.statusText);
    }
};

xhr.onerror = function() {
    console.error('Request failed');
};

xhr.send();


Enter fullscreen mode Exit fullscreen mode

DigitalOcean promotional banner stating The only cloud that makes things brighter. Simple, affordable cloud infrastructure.

11 — Closures Often Misunderstood JavaScript Terms

A closure is a feature in JavaScript where an inner function has access to the outer (enclosing) function’s variables-a scope chain. Every time you create a function, JavaScript automatically creates closures.

These closures form at the moment of the function’s creation, encapsulating and preserving the function’s scope for future use.

This mechanism is fundamental to understanding how functions interact with their surrounding state in JavaScript, allowing for powerful patterns like encapsulation and private variables.



function makeGreeting(greeting) {
    return function(name) {
        console.log(`${greeting}, ${name}!`);
    };
}

const sayHello = makeGreeting('Hello');
sayHello('Alice'); // Outputs: Hello, Alice!


Enter fullscreen mode Exit fullscreen mode

12 — Hoisting

Hoisting is JavaScript’s default behavior of moving declarations to the top of the current scope (to the top of the current script or the current function).

Understanding hoisting is crucial for managing variable and function declarations, helping avoid common pitfalls in code execution flow.



console.log(myVar); // undefined (not ReferenceError)
var myVar = 5;

hoistedFunction(); // Outputs: "This function has been hoisted."
function hoistedFunction() {
    console.log('This function has been hoisted.');
}


Enter fullscreen mode Exit fullscreen mode

13 — Prototype

Every JavaScript object has a prototype. The prototype is also an object. All JavaScript objects inherit their properties and methods from their prototype.

Prototypes are central to JavaScript’s prototype-based inheritance mechanism, allowing objects to extend others and share functionalities.



function Animal(name) {
    this.name = name;
}

Animal.prototype.speak = function() {
    console.log(`${this.name} makes a noise.`);
}

class Dog extends Animal {
    speak() {
        console.log(`${this.name} barks.`);
    }
}

const dog = new Dog('Rex');
dog.speak(); // Rex barks.


Enter fullscreen mode Exit fullscreen mode

14 — Scope

The scope is the current context of execution. The context in which values and expressions are visible or can be referred or can be referenced. If a variable or expression is not in the current scope, then it is not available for use.

Scopes control the visibility and lifetime of variables and parameters, which is fundamental to structuring and controlling the flow of a program.



function outerFunction() {
    let outer = 'I am the outer function!';

    function innerFunction() {
        console.log(outer); // Accesses outer function's variable
    }

    innerFunction();
}

outerFunction(); // Logs: I am the outer function!


Enter fullscreen mode Exit fullscreen mode

15 — This

In JavaScript, this is a keyword that refers to the object it belongs to. Its value changes dynamically depending on its usage context.

Understanding how this behaves in different contexts is key to mastering JavaScript, especially in object-oriented programming and event handling.



const person = {
    firstName: "John",
    lastName: "Doe",
    fullName: function() {
        return `${this.firstName} ${this.lastName}`;
    }
};

console.log(person.fullName()); // John Doe


Enter fullscreen mode Exit fullscreen mode

16 — ES6/ES2015 and Beyond

ES6, or ECMAScript 2015, is a major update to JavaScript that introduced many new features like classes, modules, template strings, arrow functions, and more. Subsequent updates have continued to add features.

Familiarity with ES6 and later versions is essential for writing modern, efficient, and clean JavaScript code.



const name = 'Alice';
const greet = (name) => `Hello, ${name}!`;
console.log(greet(name)); // Hello, Alice!


Enter fullscreen mode Exit fullscreen mode

Promotional image for Namecheap with a gorilla holding a glowing orb, advertising ‘.COM for just $5.98, limited time offer!

17 — Web Storage API

The Web Storage API provides two mechanisms, localStorage and sessionStorage, for storing data in the browser.

This feature enables web applications to store data for the duration of the user’s session, enhancing the user experience without relying on server storage or cookies.



// Storing data
localStorage.setItem('key', 'value');

// Retrieving data
const data = localStorage.getItem('key');
console.log(data);


Enter fullscreen mode Exit fullscreen mode

18 — Fetch API

The Fetch API offers a modern, promise-based mechanism for making network requests.

This API simplifies making HTTP requests for resources and handling responses, representing an evolution from the older XMLHttpRequest method.



fetch('https://api.example.com/data')
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));


Enter fullscreen mode Exit fullscreen mode

19 — Preflight Request

A preflight request is a type of CORS (Cross-Origin Resource Sharing) request that browsers automatically perform before carrying out a request that might have implications on user data.

Specifically, it occurs with requests that use methods other than GET, HEAD, or POST, or that use POST with certain MIME types, or that include custom headers. The preflight uses the OPTIONS method to check with the server if the actual request is safe to send.

Developers working with APIs and services across different domains must actively understand preflight requests to ensure secure handling of cross-origin requests.

20 — CORS (Cross-Origin Resource Sharing)

CORS is a mechanism that uses additional HTTP headers to tell browsers to give a web application running at one origin, access to selected resources from a different origin.

It’s a security feature to prevent malicious web applications from accessing another application’s resources.

For developers building or consuming APIs, understanding CORS is crucial for managing how resources can be requested from a domain different from the domain of the resource itself.



const express = require('express');
const app = express();

app.use((req, res, next) => {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
    next();
});

app.get('/data', (req, res) => {
    res.json({
        message: 'This is CORS-enabled for all origins!'
    });
});

app.listen(3000, () => {
    console.log('Server running on port 3000');
});


Enter fullscreen mode Exit fullscreen mode

21 — WebSockets: A Vital JavaScript Terms for Real-Time Communication

WebSockets provide a full-duplex communication channel over a single, long-lived connection, allowing for messages to be passed back and forth while keeping the connection open, in contrast to the request-response model of HTTP.

These are vital for building real-time, interactive web applications, such as live chat and gaming applications, where immediate client-server communication is required.



const socket = new WebSocket('wss://example.com/socket');

socket.onopen = function(event) {
    console.log('Connection established');
    socket.send('Hello Server!');
};

socket.onmessage = function(event) {
    console.log('Message from server', event.data);
};


Enter fullscreen mode Exit fullscreen mode

22 — Service Worker

A service worker is a script that your browser runs in the background, separate from a web page, opening the door to features that don’t need a web page or user interaction. Today, they already include features like push notifications and background sync.

Service workers are fundamental in creating reliable, fast web applications and enabling capabilities such as offline experiences, background data synchronization, and interception of network requests.



if ('serviceWorker' in navigator) {
    navigator.serviceWorker.register('/sw.js').then(function(registration) {
        console.log('Service Worker registered with scope:', registration.scope);
    }).catch(function(err) {
        console.log('Service Worker registration failed:', err);
    });
}


Enter fullscreen mode Exit fullscreen mode

Skillshare promotional image featuring pottery making with the text ‘Work in progress. Join With 30% Off.

23 — Progressive Web App (PWA)

PWAs are a type of application software delivered through the web, built using common web technologies, including HTML, CSS, and JavaScript.

They should work on any platform that uses a standards-compliant browser, including both desktop and mobile devices.

PWAs offer an app-like user experience, supporting features like offline operation, background data refresh, and push notifications, which enhance the mobile user experience significantly.

24 — Promises and Async/Await

While previously mentioned, it’s worth emphasizing the importance of these concepts in handling asynchronous operations in JavaScript.

Promises offer a cleaner, more robust way of handling asynchronous operations compared to older techniques like callbacks.

Async/await syntax provides a more straightforward method to write asynchronous code, making it look and behave like synchronous code.



// Using Promises
fetch('https://api.example.com/data')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

// Using async/await
async function fetchData() {
try {
const response = await fetch('https://api.example.com/data');
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error:', error);
}
}

fetchData();

Enter fullscreen mode Exit fullscreen mode




25 — Tree Shaking

Tree shaking is a term commonly used in JavaScript and web development to describe removing unused code from your final bundle during the build process.

It helps in reducing the size of your application’s bundle, leading to faster load times and improved performance.

26 — SSR (Server-Side Rendering)

SSR is rendering web pages on the server instead of rendering them in the browser. When a user requests a page, the server generates the HTML content for that page and sends it to the user’s browser.

SSR can significantly improve the performance and SEO of web applications by allowing search engines to index the content and provide faster initial page loads.

27 — CSR (Client-Side Rendering)

CSR is where the browser renders the web page using JavaScript. Instead of retrieving all the content from the HTML document itself, the system provides a basic structure and uses JavaScript to populate the content.

CSR can lead to more dynamic and interactive web applications but requires considerations around SEO and initial load performance.

28 — Virtual DOM

The Virtual DOM is a concept used in some JavaScript frameworks, like React, to improve app performance and user experience.

It’s a lightweight copy of the real DOM in memory, and instead of updating the DOM directly, changes are first made to the Virtual DOM, which then efficiently updates the real DOM.

Understanding the Virtual DOM is crucial for developers working with libraries and frameworks that use this concept for optimizing rendering processes.

29 — Webpack

Webpack is a static module bundler for modern JavaScript applications. It processes applications and bundles all the files (modules) together.

Understanding Webpack is important for developers aiming to optimize the loading time and performance of web applications.

30 — Babel

Babel is a JavaScript compiler that allows developers to use next-generation JavaScript today. It transforms ES6 and beyond into backward-compatible versions of JavaScript.

Babel is essential for ensuring that web applications can run on older browsers, enhancing compatibility and user reach.

31 - NPM (Node Package Manager)

NPM is the world’s largest software registry, used for sharing and borrowing packages of JavaScript code.

Knowledge of NPM is crucial for managing dependencies in projects, sharing your own projects, and installing utilities and frameworks.

Explore the fundamentals of coding with ‘Eloquent JavaScript, Third Edition’ by Marijn Haverbeke.

32 — SPA (Single Page Application)

SPAs are web applications that load a single HTML page and dynamically update that page as the user interacts with the app.

SPAs offer a more fluid user experience similar to a desktop application, important for developers building interactive, modern web applications.

33 — SSG (Static Site Generator)

SSGs are tools that generate a full static HTML website based on raw data and templates. They pre-render pages at build time.

SSGs are gaining popularity for their speed, security, and ease of deployment, especially for blogs, documentation, and marketing websites.

34 — JSONP (JSON with Padding)

JSONP is a method for sending JSON data without worrying about cross-domain issues. It uses a script tag with a callback function to receive the data.

While somewhat outdated because of CORS and modern browser capabilities, understanding JSONP is useful for dealing with legacy systems or as part of web development history.

35 — Cross-Browser Compatibility

Cross-browser compatibility ensures that web applications function correctly and consistently across different web browsers.

Addressing compatibility issues is crucial for reaching a broad audience and involves using tools like Babel for JavaScript transpilation and polyfills to emulate missing features.

36 — Environment Variables

JavaScript applications securely manage configuration settings and sensitive information using environment variables.

Especially in server-side environments like Node.js, environment variables allow developers to separate configuration from code, enhancing security and flexibility.



console.log(process.env.API_KEY);

Enter fullscreen mode Exit fullscreen mode




37 — Web Components

Web Components represent a suite of different technologies allowing developers to create reusable custom elements with encapsulation.

This modern approach to web development streamlines building complex interfaces, promoting code reuse and maintainability.

38 — Error Handling

Effective error handling in JavaScript involves strategies for anticipating and managing errors gracefully.

Using try/catch blocks, error event listeners, and handling rejected promises are all critical practices for writing robust, fault-tolerant code that enhances application reliability and user experience.



try {
// Code that may throw an error
} catch (error) {
console.error('Error caught:', error);
}

Enter fullscreen mode Exit fullscreen mode




39 — Callback Hell and Promises

Early JavaScript relied heavily on callbacks for asynchronous operations, leading to callback hell due to deeply nested callbacks.

Promises were introduced as a cleaner alternative, allowing asynchronous operations to be chained and managed more efficiently.



// Callback Hell Example
getData(function(a) {
getMoreData(a, function(b) {
getMoreData(b, function(c) {
console.log(c);
});
});
});

// Promises Example
getData()
.then(a => getMoreData(a))
.then(b => getMoreData(b))
.then(c => console.log(c))
.catch(error => console.error(error));

Enter fullscreen mode Exit fullscreen mode




40 — Serverless Functions

Serverless functions allow developers to run backend code in response to events triggered by web applications without managing server infrastructure, scaling automatically with demand.



// Example of a serverless function in AWS Lambda (Node.js)
exports.handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify({
message: "Hello World"
})
};
};

Enter fullscreen mode Exit fullscreen mode




41 — WebAssembly

WebAssembly (Wasm) enables high-performance applications in the browser, allowing developers to use languages like C++ for web development tasks that require computational intensity.



// Loading a WebAssembly module example
WebAssembly.instantiateStreaming(fetch('module.wasm'), {})
.then(result => {
// Use exported Wasm functions
});

Enter fullscreen mode Exit fullscreen mode




42 — Accessibility (A11y)

Ensuring the accessibility of web applications allows them to be used by as many people as possible, including those with disabilities. JavaScript can enhance accessibility by dynamically updating ARIA attributes.



// Dynamically updating ARIA attributes with JavaScript
document.getElementById('menu').setAttribute('aria-expanded', 'true');

Enter fullscreen mode Exit fullscreen mode




43 — Internationalization and Localization

To prepare applications for a global audience, one must internationalize them so that one can easily localize them for different languages and cultures.



// Example of internationalizing dates in JavaScript
const date = new Date();
const options = {
year: 'numeric',
month: 'long',
day: 'numeric'
};
console.log(new Intl.DateTimeFormat('en-US', options).format(date));

Enter fullscreen mode Exit fullscreen mode




44 — CRUD Basic JavaScript Terms

CRUD refers to the four basic operations of persistent storage. It is a mnemonic for the typical operations implemented in relational database applications.

Knowing CRUD operations is foundational for any developer working with databases or any form of data storage, as it covers the essential actions you can perform on data.

45 — Performance Optimization Techniques

Optimizing JavaScript performance involves techniques like lazy loading components, code splitting, and optimizing dependencies to make web applications faster and more responsive.



// Lazy loading a module with dynamic imports
import('path/to/module').then(module => {
module.doSomething();
});

Enter fullscreen mode Exit fullscreen mode




Final Thoughts on JavaScript Essential Terms

Embarking on this journey through the essential terms of JavaScript, we’ve covered a vast terrain-from the foundational elements that every web developer encounter, like payloads and the DOM, to more complex concepts such as the event loop and prototypal inheritance.

JavaScript is the heartbeat of modern web development, and understanding its key terms is akin to mastering the language of the web.

As you continue to explore and apply these concepts, remember that each term is a building block in your development skills.

Keep experimenting, keep learning, and most importantly, keep coding.

The path to mastering JavaScript is ongoing, but with the essential terms covered in this guide, you’re well-equipped to tackle the challenges and opportunities that come your way in the world of web development.

Support Our Tech Insights

Buy Me A Coffee

Donate via PayPal button

Note: Some links on this page might be affiliate links. If you make a purchase through these links, I may earn a small commission at no extra cost to you. Thanks for your support!

Top comments (1)

Collapse
 
valvonvorn profile image
val von vorn

Very essential maybe, but what has Web Assembly to do with it and why must Every Developer know that?