Convert a JSON object with circular references to a JavaScript string
Circular JSON objects can't be serialized using JSON.stringify()
, but you can use this trick to handle them.
Browse snippets by collection or check out our top picks and latest articles below.
Circular JSON objects can't be serialized using JSON.stringify()
, but you can use this trick to handle them.
Use a simple JavaScript trick to validate a serialized JSON object.
Using an HTML element, you can easily make all links in your document open in a new tab. Learn how with this quick tip.
Learn how to shuffle, sample and perform weighted selection on JavaScript arrays.
Use JavaScript to generate a random alphanumeric string of a specified length.
Combining Math.random()
and a few simple math operations, you can generate an array of random integers in a specified range.
Testing React components that update asynchronously is pretty common. Learn how to deal with common issues and speed up your testing.
Calculate a SHA-256 hash in JavaScript using native APIs in both the browser and Node.js.
Learn how you can leverage the Proxy object to use a JavaScript object the same way as you would use a regular array.
Creates a horizontally scrollable image gallery.
A graph is a data structure consisting of a set of vertices connected by a set of edges.
Creates a card that shifts on hover.