Data Structure Visualizer - Online Array, Stack, Queue
Add, remove, push, pop items and watch the data structure change visually. Supports arrays, stacks, and queues. For CS students.
UD5 Toolkit
| Feature | Map | WeakMap | Set | WeakSet |
|---|---|---|---|---|
| Key / Value Type | Any type | Keys: Objects only | Any type | Values: Objects only |
| Iterable | Yes | No | Yes | No |
| .size property | Yes | No | Yes | No |
| .clear() method | Yes | No | Yes | No |
| Key references | Strong | Weak (GC-friendly) | Strong | Weak (GC-friendly) |
| Prevents GC of keys | Yes (risk of leak) | No | Yes (risk of leak) | No |
| Common Use Case | General key-value storage | Object metadata, caches, private data | Unique value collections | Object tagging / "processed" markers |
// WeakMap: Store DOM element metadata without memory leaks
const elementData = new WeakMap();
function attachData(el, data) {
elementData.set(el, data);
}
function getData(el) {
return elementData.get(el);
}
// When the DOM element is removed, its WeakMap entry
// becomes eligible for garbage collection automatically.
// No manual cleanup needed — no memory leak!
The fundamental difference lies in how they hold references to their keys:
Because of weak references, WeakMap keys must be objects (not primitives), and WeakMaps are not iterable — you cannot enumerate their contents because entries may disappear at any time.
WeakMap and WeakSet are non-iterable by design. The reason is tied to garbage collection:
The lack of iteration is not a limitation — it's a feature that ensures weak references remain truly weak and GC-friendly.
For the same reason they're not iterable: the size is non-deterministic. Entries can be garbage collected at any time, so the count would constantly change in ways that JavaScript can't reliably track. Exposing a .size would give a false sense of precision. If you need to know the size or iterate entries, use a regular Map or Set instead.
WeakMap excels in scenarios where you need to associate data with objects without preventing their garbage collection:
WeakSet is ideal for tagging or marking objects:
JavaScript engines use mark-and-sweep garbage collection. Here's how it interacts with weak collections:
Important: GC timing is non-deterministic. You cannot predict exactly when an object will be collected. Use FinalizationRegistry to get callbacks when specific objects are GC'd.
Yes, absolutely. WeakMap and WeakSet are specifically designed to prevent a common class of memory leaks:
This is why frameworks like Vue 3, Svelte, and modern libraries use WeakMap extensively for internal bookkeeping.
FinalizationRegistry provides callbacks when registered objects are garbage collected, but with important caveats:
It's a useful diagnostic tool but not a substitute for proper memory management.
Both WeakMap and WeakSet have excellent browser support:
WeakMap and WeakSet are safe to use in production without polyfills for virtually all modern web applications.
Add, remove, push, pop items and watch the data structure change visually. Supports arrays, stacks, and queues. For CS students.
Apply realistic reverbs (cathedral, hall, room) to any audio using pre‑loaded impulse responses. Hear the difference instantly.
Compress and decompress text using the browser's native Compression Streams API. See the binary output size.
Paste your JSON‑LD or Microdata and test it against Google's Rich Results criteria. Get warnings. Local linter.
Paste a line of poem and see which syllable stresses create a particular meter. Educational tool.
Translate text into semaphore flag positions and decode semaphore back to letters. Interactive animated flags. For scouts and maritime fans.
Drop a file to see its MIME type and the first few magic bytes (hex and ASCII). No upload, works instantly.
Generate a humorous, realistic‑looking git commit message. Perfect for testing or filling mock repos.
Drop a file and see its detected type based on the first bytes (magic number). Identifies hundreds of formats. Local.
Parse a Snowflake ID (used by Discord, Twitter) into its timestamp, worker, and sequence components. Instant local decoding.
Paste raw email headers and see authentication results (SPF, DKIM, DMARC) in a readable table. Find spoofing attempts.
Paste word pairs (or load pre-made sets) and practice with randomized flashcards. Flip to reveal translation, mark as known/unknown. Local data, no login.
Create a DMARC policy record with percentage, reporting addresses, and alignment mode. Validate and copy the final DNS TXT.
Toggle between full and reduced motion on a live animated page. See how to design for vestibular disorders. Educational.
Paste N‑Triples data and convert it to a compact JSON‑LD representation. Work with linked open data. Local.
Enter a list of buzzwords or concepts and shuffle them into random pairs. Stimulate creative thinking. All local.
Split a secret string into N shares where K are needed to recover. Educational cryptography demo. Uses simple XOR-based scheme. Local.
Paste a `Set‑Cookie` header and see all attributes parsed: domain, path, Max‑Age, SameSite, Secure, HttpOnly. Debug cookies easily.
Enter text and see each character's 8‑bit binary laid out in a black‑and‑white grid. Beautiful data art. Local.
Shrink a PDF file size with configurable image quality and object removal. All processing stays in your browser.
Generate cryptographically secure BIP39 mnemonic phrases (12 or 24 words) for HD wallet seeds. All entropy generated locally.
Set up first‑line indentation and hanging punctuation. See how they affect reading flow. Copy the CSS.
Compress text with Brotli at different quality levels. See size reduction and time. Find the sweet spot for your static assets.
Paste an ASCII‑armored PGP message and view its packet structure. See the encrypted/plaintext blocks without decrypting.
Search for any file extension to see its full name, MIME type, and description. Covers thousands of entries. Static data.
Query DNS records for any domain directly from your browser using DNS-over-HTTPS. See A, AAAA, MX, CNAME, and TXT records. No logs.
Simulate forced‑colors mode and see how your site looks. Adjust CSS system colors. Make your design accessible.
Simulate adaptive bitrate logic by switching between different quality video segments. See how ABR algorithms work.
See how a full paragraph looks with your chosen text and background colors. Not just a ratio; the real appearance.
Watch classic sorting algorithms step through a randomized bar chart. Adjust speed and array size. Great for learning algorithm efficiency.