Skip to main content Accessibility Feedback

Extract & Copy Properties

structuredClone()

The structuredClone() method accepts an array or object as an argument, and returns a deep copy or deep clone.

// A multidimensional array
let wizards = [{
	name: 'Radagast',
	color: 'brown'
}, {
	name: 'Gandalf',
	color: 'gray'
}];

// Create a copy of the wizards array
let wizardsCopy = structuredClone(wizards);

Preorder my new course on Web Components! Want to learn how to build Web Components from scratch, master best practices, and more? Preorder today and get $100 off of the launch price.


Find this useful? You can support my work by purchasing an annual membership.