Keyed Collections
The ES6 keyed collections — Map, Set, WeakMap, and WeakSet — are not available in SSJS. The SFMC Jint engine predates ES2015, so all four are undefined and cannot be constructed.
The ES6 keyed collections are not available in SSJS. The SFMC server-side JavaScript engine (Jint) implements an ES3/ES5-era dialect and predates ES2015, so Map, Set, WeakMap, and WeakSet are entirely absent. Each is undefined, and new Map() (etc.) throws Unknown type: Map.
Status legend
| Icon | Meaning |
|---|---|
| ❌ Missing | Not available (typeof is "undefined"; new throws Unknown type) |
Members
| Member | ES | Status | Notes |
|---|---|---|---|
Map |
ES6 | ❌ Missing | Use a plain object as a string-keyed dictionary |
Set |
ES6 | ❌ Missing | Use a plain object whose keys are the members |
WeakMap |
ES6 | ❌ Missing | No weak-reference collections exist |
WeakSet |
ES6 | ❌ Missing | No weak-reference collections exist |
Map
(ES6) — ❌ Missing. Map is not defined — typeof Map === "undefined" and new Map() throws Unknown type: Map.
For string-keyed lookups, use a plain object as a dictionary:
// Instead of: var m = new Map(); m.set("a", 1);
var m = {};
m["a"] = 1;
Write(m["a"]); // 1
Write("a" in m ? "has" : "no"); // note: the `in` operator is unsafe in CloudPages —
// prefer: (typeof m["a"] != "undefined")
Object keys are always coerced to strings, so a plain object cannot key by object identity or preserve insertion order the way a real Map does.
Set
(ES6) — ❌ Missing. Set is not defined — typeof Set === "undefined" and new Set() throws Unknown type: Set.
Emulate a set of strings with a plain object whose keys are the members:
// Instead of: var s = new Set(); s.add("x");
var s = {};
s["x"] = true;
Write(typeof s["x"] != "undefined" ? "member" : "absent"); // "member"
WeakMap
(ES6) — ❌ Missing. WeakMap is not defined — typeof WeakMap === "undefined" and new WeakMap() throws Unknown type: WeakMap. There is no weak-reference mechanism in this engine; use a plain object dictionary (which holds strong references) and delete keys manually when done.
WeakSet
(ES6) — ❌ Missing. WeakSet is not defined — typeof WeakSet === "undefined" and new WeakSet() throws Unknown type: WeakSet. As with WeakMap, no weak-reference collection is available.