Loading topic
Map and Set. It also assumes you know from the previous chapter that a variable holding an object holds a reference to it, not the object itself.5 min readstructuredClone was built in, the usual way to get a deep copy in JavaScript was one line: JSON.parse(JSON.stringify(value)). You will still see it in older codebases, Stack Overflow answers and utility files. It works for some data. For other data it quietly changes or drops values, and 6 min readMap, Set and Date. It also assumes you have read the earlier chapter that introduced structuredClone(value). Every example runs in a modern browser console or in Node.js 17 or later.6 min read=== operator, basic Map and Set use, and try/catch. It also assumes you have read the earlier chapters on shallow copies, the JSON round-trip, and the basics of structuredClone.7 min readstructuredClone copies plain objects, arrays, Date, Map and Set, and that you are comfortable with try/catch. The examples run in Node.js 17 or later or in a browser console. The DOM example needs a browser.6 min readstructuredClone makes deep copies and which built-in types it supports (covered in earlier chapters). You should also be comfortable with ES classes, getters and setters, and Object.defineProperty.7 min readstructuredClone copies and what it drops. Before you rely on it in real code, check one more thing: whether the runtime that runs your code provides it. This chapter covers which browsers and server runtimes have it, why some environments still lack it, how to detect i7 min readstructuredClone makes deep copies, that ArrayBuffer and typed arrays such as Uint8Array are on its list of supported types, and how a DataCloneError is thrown. You should also be able to run code in Node.js 17 or later, or in a modern browser console6 min readstructuredClone was not new when browsers added it. The structured clone algorithm had already been part of the web platform for years. Every time you send a message to a worker, store a record in IndexedDB, or push state onto the browser history, the platform runs this algorithm. `structuredClone6 min readstructuredClone keeps and drops, and which values make it throw a DataCloneError.6 min read