Koppelingen in nieuw tabblad openen
  1. LocalStorage is a web storage mechanism that allows you to store key-value pairs in a web browser. Unlike cookies, the data stored in localStorage has no expiration time and persists even after the browser is closed. This makes it useful for storing data that needs to be available across multiple sessions.

    Key Features

    • Persistence: Data stored in localStorage remains until explicitly deleted.

    • Scope: Data is scoped to the origin (protocol, domain, and port) of the page.

    • Storage Limit: Typically, browsers allow around 5MB of storage per origin.

    Basic Operations

    Setting Data

    To store data in localStorage, use the setItem method:

    localStorage.setItem("key", "value");
    Gekopieerd.

    Example:

    localStorage.setItem("lastname", "Smith");
    Gekopieerd.

    Getting Data

    To retrieve data from localStorage, use the getItem method:

    let value = localStorage.getItem("key");
    Gekopieerd.

    Example:

    let lastname = localStorage.getItem("lastname");
    Gekopieerd.

    Removing Data

    To remove a specific item from localStorage, use the removeItem method:

    localStorage.removeItem("key");
    Gekopieerd.
  1. Window: localStorage property - Web APIs | MDN - MDN Web Docs

    The localStorage read-only property of the window interface allows you to access a Storage object for the Document's origin; the stored data is saved across browser sess…
    Value

    Exceptions
    SecurityError Thrown in one of the following cases: •The origin is not a valid scheme/host/port tuple. This can happen if the origin uses the file: or data: schemes, for example. •The request violates a polic…

    Description

    The keys and the values stored with localStorage are always in the UTF-16 string format, which uses two bytes per character. As with objects, integer keys are automatically converted to strings.
    localStorage data is specific to the protoc…

    Examples

    The following snippet accesses the current domain's local Storage object and adds a data item to it using Storage.setItem().
    The syntax for reading the localStorage item is as follows:
    The syntax for removing the localStorage i…

    Browser compatibility

    BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

  2. javascript - Storing Objects in localStorage - Stack Overflow

    It's easy to store objects in local storage with localDataStorage, where you can transparently set/get any of the following "types": Array, Boolean, Date, Float, Integer, Null, Object or String.

    • Recensies: 5
    • Window localStorage Property - W3Schools

      Set and retrieve localStorage name/value pair: More examples below. The localStorage object allows you to save key/value pairs in the browser. The localStorage object stores data with no expiration …

    • How to Use LocalStorage in JavaScript - freeCodeCamp.org

      20 feb. 2024 · In this article, you learn about how to use local storage. We covered saving, retrieving, and deleting data from local storage. You also learned about some of the benefits of using local storage …

    • localStorage in JavaScript: A complete guide

      28 feb. 2024 · localStorage is a property that allows JavaScript sites and apps to save key-value pairs in a web browser with no expiration date. This means the …

    • JavaScript localStorage - GeeksforGeeks

      23 jul. 2025 · JavaScript localStorage is a feature that lets you store data in your browser using key-value pairs. The data stays saved even after you close the …

    • JavaScript localStorage Explained for Beginners

      16 jan. 2026 · Learn how JavaScript localStorage works with simple examples. Understand setItem, getItem, clear, and how to store arrays and objects using JSON.

    • JavaScript - Local Storage - Online Tutorials Library

      Window.localStorage is a read-only property that returns a reference to a local storage object which is intended to store data that can only be accessed by the origin that created it.

    • How to Use localStorage in JavaScript - strapi.io

      28 mei 2025 · localStorage in JavaScript allows client-side data persistence. In other words, it enables data to remain in the browser even after a page is closed. …

    • Web Storage API - W3Schools

      The localStorage object provides access to a local storage for a particular Web Site. It allows you to store, read, add, modify, and delete data items for that domain.

    • Mensen vragen ook naar
      Laden
      Kan antwoord niet laden