How it works...

Just like the Set constructor, the WeakSet constructor takes an iterable. Each element of the array is added in turn. We'll note that multiple instances have the same name property. This is, of course, because they are separate Rocket instances, despite having the same name 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.