SkillAgentSearch skills...

DeepClone

Utility for cloning objects and arrays so you can manipulate them without borking your original data

Install / Use

/learn @Rich-Harris/DeepClone
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

deepClone.js

Simple utility to deep clone objects and arrays, for when you want to modify or transform data without borking the original.

a = { one: 1, two: 2, three: 3 };
b = a;

b.four = 4;
console.log( a.four ); // 4


a = { one: 1, two: 2, three: 3};
b = deepClone( a );

b.four = 4;
console.log( a.four ); // undefined

Not exactly rocket science. Just a handy thing to have lying around. Doesn't check for cyclical references, so if you get stuck in an infinite loop it's you're own fault.

MIT licensed.

Related Skills

View on GitHub
GitHub Stars19
CategoryDevelopment
Updated2y ago
Forks0

Languages

JavaScript

Security Score

60/100

Audited on Feb 3, 2024

No findings