How it works...

No surprises here, the WeakMap constructor adheres to the same interface as Map. The only difference is the type restriction on key. The argument for the constructor is a two-dimensional array, where the outer dimension is the list of entries. The inner dimension represents the key-value pairs. The first member of the inner dimension is the key, and the second is the value.

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.