On this page
  1. Map.get
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

Map.get

Prev: Map | Up: Map | Next: has
Rel: Map, Collections Guide
Ref: MDN Web Docs — Map.get
Tags: #public #web #javascript #builtins #map #tier/core


Signature & Overview

map.get(key)  /* + map.set(key, val) */

Retrieves the value associated with key (or undefined); set() inserts/updates and returns map for chaining.

Notes & Pitfalls

Example

const cache = new Map([["host", "localhost"]]);
console.assert(cache.get("host") === "localhost");
console.assert(cache.get("missing") === undefined);

Linked from

Related notes