ES14 introduced WeakMap allow Symbol keys
Before ES14, WeakMap allows only Object Keys, that allows to unique keys eligible garbage collection.
---
title: W3schoolsio ES14 Array immutable Methods
---
%%{init: {"flowchart": {"htmlLabels": false}} }%%
flowchart TD
markdown["`**ES14(ECMAScript2023)**`"]
hashbang["`**WeakMap Symbol Keys**`"]
markdown --> hashbang
ES14 WeakMap Symbol Keys
Map contains key and values. WeakMap allow you to garbage unique keys. Symbol is a primitive unique symbol used as a key in it.
Here is an example
const weakMap = new WeakMap();
const key = Symbol("name");
weakMap.set(key, "Employee1");
console.log(weakMap.get(key)); // 👉🏼 Employee1