To recreate a JavaScript object, you make a new object whose data matches the original but whose reference is different. The safest default depends on what's inside: use the spread operator or Object.assign for flat objects with only primitive values, and use structuredClone when the object contains nested objects, arrays, dates, maps, sets, or other built-in types. Neither approach copies methods, getters as getters, or a class prototype; recreating those requires an explicit rebuild step. "Recreate" is ambiguous in practice, so this guide separates four distinct goals: shallow copy, deep clone, rebuilding with a transformed shape, and restoring a class instance from plain data. Picking the wrong one is the most common source of bugs, especially shared nested references that mutate in two places at once.

The mechanics matter more than the one-liners. JavaScript objects are reference values, so const copy = original doesn't recreate anything; it just adds a second name for the same object. Everything below builds a genuinely separate object and explains what survives the trip.

What "Recreating" an Object Actually Means in JavaScript

Every assignment of an object stores a reference. Two variables can point to the same heap object, so mutating through one is visible through the other. Recreating means allocating a new object and populating it from the source.

There are four realistic targets:

Shallow copy: a new top-level object; nested objects and arrays are still shared. Deep clone: a new object at every level, with no shared references (for supported types). Structural rebuild: a new object with a different shape, renamed keys, filtered fields, or computed values. Instance restoration: turning plain data back into a class instance with its prototype and methods.

A successful recreation has two properties you can check: the new object is not === the original, and any mutation you make to the copy doesn't appear in the original (at the depth you intended to isolate).

Prerequisites Before You Copy Anything

Before choosing a method, answer three questions about your source object and target environment.

1: What types does it contain? Primitives (strings, numbers, booleans, null, undefined, bigint, symbol), plain nested objects, arrays, Date, Map, Set, RegExp, typed arrays, functions, class instances, or cycles (an object referencing itself). 2: Which runtime will run the code? structuredClone is a global in modern browsers and in Node.js 17 and later. It's not available in older environments. 3: How deep must isolation go? If you only read from the copy, a shallow copy is fine. If you mutate nested state, you need a deep clone or an immutable update pattern.

For the examples below, assume this source:

Method 1: The Spread Operator for Flat, Primitive-Only Objects

The spread operator builds a new object and copies own enumerable properties. It's the clearest syntax for settings, form state, and DTOs with only primitive values.

This is a shallow copy. copy !== order is true, but copy.customer === order.customer is also true. That's fine when every value is a primitive, and dangerous the moment a nested object or array appears.

Symbol-keyed properties are copied if they're enumerable own symbols, which spread does include. Non-enumerable properties are skipped, and prototype members are never copied.

Method 2: Object.assign for Merging and Defaults

Object.assign(target, ...sources) copies own enumerable properties from sources into a target and returns the target. It behaves like spread for copying, with two practical differences: you must pass an empty object as the target to avoid mutating the source, and it's handy for layering defaults.

Again, this is shallow. There's also a classic trap: Object.assign(order, { id: 7 }) mutates order. Always lead with {} (or Object.create(null) if you need a prototype-free dictionary).

Method 3: structuredClone for Deep Copies of Supported Types

structuredClone(value) performs a deep clone using the structured clone algorithm. It handles nested objects and arrays, Date, Map, Set, RegExp, ArrayBuffer and typed arrays, Blob, and cyclic references. It throws a DataCloneError on functions, DOM nodes, and class instances with methods that can't be serialized.

Two behavior notes worth knowing. First, property descriptors aren't preserved: getters are evaluated and replaced with plain data properties, and non-enumerable properties are dropped. Second, the prototype is lost — a structuredClone of a class instance returns a plain object.

You can carry over transferable resources (like ArrayBuffer) with the second argument, but only when you intend to move ownership rather than copy.

Method 4: JSON Round-Trip, and Why It Quietly Corrupts Data

The old trick JSON.parse(JSON.stringify(obj)) produces a deep copy, but it silently changes types. Date becomes an ISO string. undefined properties and function-valued properties vanish. Map and Set become {}. NaN and Infinity become null. Cyclic structures throw. BigInt throws.

That makes it acceptable for pure JSON data — API payloads that were JSON to begin with — and wrong for anything holding live objects. If a colleague's "clone" suddenly turned a Date into a string and broke getFullYear(), this is usually why.

The table below compares the main approaches on criteria that actually change your choice.

Method Depth Handles Date/Map/Set Preserves prototype Handles cycles Best for
Spread {...o} Shallow Copies references No N/A (shallow) Flat settings, form state
Object.assign({}, o) Shallow Copies references No N/A (shallow) Merging defaults
structuredClone(o) Deep Yes No Yes Nested data, modern runtimes
JSON round-trip Deep No (Date→string) No No (throws) Pure JSON payloads only
Manual rebuild Whatever you write Whatever you write Yes, if you set it If you handle it Class instances, transformed shapes

Rebuilding an Object With a New Shape

Often "recreate" means constructing a fresh object with different keys or filtered data rather than cloning. Destructuring with rest is the cleanest tool.

A few mapping patterns worth keeping in your head:

Rename: { userId: o.id, ...rest } after pulling id out. Whitelist: build explicitly from named fields so unexpected keys never leak through. Blacklist: const { password, ...safe } = user; removes sensitive fields — but only at the top level. Transform: Object.fromEntries(Object.entries(o).map(([k, v]) => [k, fn(v)])).

For arrays of objects, map plus spread produces an array of new objects: items.map(i => ({ ...i, qty: i.qty + 1 })). Note that map alone gives a new array but the same element references, so the spread inside is what isolates each record.

Restoring a Class Instance From Plain Data

Prototypes don't survive clone operations. To recreate an instance, build it through its constructor or a static factory and assign the data.

The constructor is the rehydration boundary: it validates input, converts strings back to Date, and guarantees the prototype is correct. For more complex cases, Object.setPrototypeOf(plain, Order.prototype) works but skips validation and constructor logic, so I'd reserve it for controlled migrations.

Methods defined on the prototype come back automatically once the prototype is set; methods defined as own properties (arrow functions assigned in the constructor) would need explicit reassignment because they're functions, which cloning can't serialize.

Worked Example: A Safe Recreate-and-Update Flow

Put the pieces together for a common task: take an order, produce an updated copy, and confirm the original is untouched.

Verification, in order:

1: updated !== order — different references. 2: order.items.qty is still 2 — deep isolation held. 3: updated.placedAt instanceof Date — type survived. 4: order.items === updated.items is false — no shared nested references.

If checks 1 or 4 fail, you used a shallow method or shared a reference. If check 3 fails, a JSON round-trip crept in.

Arithmetic sanity check on the example: the original order totals 2 units; the updated copy totals 5 units, a difference of 3 units. Since structuredClone isolates items, the original stays at 2 after the update. That's a reproducible check you can assert in a test.

Common Failure Modes and How to Spot Them

Shared nested state after a "copy." Symptom: changing the copy changes the original one level down. Cause: spread or Object.assign on a nested object. Reversible fix: switch to structuredClone or copy each nested level explicitly.

Silent type drift. Symptom: date.getTime is not a function, or undefined keys missing from the copy. Cause: JSON round-trip. Fix: structuredClone for rich data; reserve JSON for payloads that were JSON to begin with.

DataCloneError. Symptom: clone throws on functions, DOM nodes, or class instances. Cause: structured clone can't serialize them. Fix: rebuild through a constructor, or strip non-serializable fields first.

Cycles. Symptom: structuredClone handles self-references; JSON throws "Converting circular structure to JSON." Fix: use structuredClone, or a library with a cycle-aware algorithm.

Lost getters and non-enumerable properties. Symptom: a computed property turns into a stale snapshot. Cause: clone algorithms read values and write plain properties. Fix: rebuild via the constructor so getters live on the prototype.

Merging mutation. Symptom: the "source" object changed after a merge. Cause: Object.assign(source, ...) without an empty target. Fix: Object.assign({}, source, updates).

If the object's shape is failing validation or the instance methods still don't behave after a constructor-based rebuild, stop patching and reproduce the minimal object in isolation. That's the point where a library or a schema validator (for example, a runtime type checker) is the sensible next step rather than more ad hoc copying.

Choosing the Right Method Quickly

Match the method to the object, not the mood.

Flat object, primitives only: spread. Flat object plus defaults: Object.assign({}, defaults, source). Nested data, modern runtime: structuredClone. Pure JSON payload: JSON round-trip or structuredClone (both fine; structuredClone is stricter and faster to reason about). Class instance or methods needed: constructor-based rebuild. Different shape: destructuring and explicit mapping.

One more consideration: performance. Deep cloning costs time proportional to object size, so cloning a large array of records on every keystroke in a UI is a real cost. For state updates, prefer targeted immutable updates (copy only the path you change) over cloning the whole tree. And when the source contains functions or DOM references, no general-purpose clone will do the job — write the rebuild.

The core discipline is the same across all four meanings: assert reference inequality, assert nested isolation at the depth you need, and assert that types survived. Those three checks catch nearly every recreation bug before it reaches production.