Use Native structuredClone() Instead of JSON.parse(JSON.stringify())

Use Native structuredClone() Instead of JSON.parse(JSON.stringify())

●2 ●12 ●32
calendar_today • schedule1 min read

Deep cloning objects in JS used to require third-party libraries like Lodash or hacky JSON serialization that dropped Date objects, Map, Set, and RegExp.

JavaScript
const original = {
user: "Joseph",
joined: new Date(),
roles: new Set(["admin", "designer"]),
};

// Loses Date instances and sets
const badClone = JSON.parse(JSON.stringify(original));

// Native browser & Node.js deep clone (zero dependencies)
const cleanClone = structuredClone(original);

Why it changes your career: Replacing heavy third-party utility libraries with native browser APIs shrinks your bundle size and eliminates unnecessary dependency risks.

Want more #webdev & #javascript deep dives?

Join 6,095+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

More Posts

TypeScript Complexity Has Finally Reached the Point of Total Absurdity

Karol Modelski - Apr 23

I’m a Senior Dev and I’ve Forgotten How to Think Without a Prompt

Karol Modelski - Mar 19

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

The Memory Leak in addEventListener You’re Ignoring

Joemetry - Oct 15

Three Design-to-Code Rules Most Developers Ignore (That Will Make You a Better Engineer)

Joemetry - Sep 26
chevron_left
933 Points • 46 Badges
Abuja, Nigeria • byjoemetry.com
12Posts
26Comments
10Connections
Joseph Salaki is a Visual Designer and Frontend Developer specializing in brand identity systems and digital design. byJoemetry.com

Related Jobs

View all jobs →

Commenters (This Week)

2 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!