Map getOrInsert()Baseline · Newly available
The getOrInsert() and getOrInsertComputed() methods of Map objects get a value, setting and getting a default value if needed.
Works in the latest version of every major browser, but older devices may not support it yet. Baseline since Feb 14, 2026.
Browser support
DesktopChrome
1–144Not supported
145+Supportedsince Feb 10, 2026
Current: 155Edge
12–144Not supported
145+Supportedsince Feb 14, 2026
Current: 154Firefox
1–143Not supported
144+Supportedsince Oct 14, 2025
Current: 157Safari
1–26.1Not supported
26.2+Supportedsince Dec 12, 2025
Current: 27MobileChrome Android
18–144Not supported
145+Supportedsince Feb 10, 2026
Current: 155Firefox Android
4–143Not supported
144+Supportedsince Oct 14, 2025
Current: 157Safari iOS
1–26.1Not supported
26.2+Supportedsince Dec 12, 2025
Current: 27How to use
Every current browser supports this, but it only became Baseline on Feb 14, 2026. Use it as a progressive enhancement, or keep a fallback if you support older devices.
Example
Full syntax and examples are on MDN: getOrInsert.
Feature detection
JS · check before using
if ("getOrInsert" in Map || ("prototype" in Map && "getOrInsert" in Map.prototype)) {
// Map.getOrInsert is available
}Documentation (MDN)
Specification
Sub-features
Support for each part of the feature (4). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| Map.getOrInsert | 145 | 145 | 144 | 26.2 | 145 | 144 | 26.2 |
| Map.getOrInsertComputed | 145 | 145 | 144 | 26.2 | 145 | 144 | 26.2 |
| WeakMap.getOrInsert | 145 | 145 | 144 | 26.2 | 145 | 144 | 26.2 |
| WeakMap.getOrInsertComputed | 145 | 145 | 144 | 26.2 | 145 | 144 | 26.2 |