Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Copies/Clones any variable so all references to the original object are stripped

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.md

JavaScript Object Clone

Copies/Clones any variable so all references to the original object are stripped.

Example usage:

var obj1 = {
  'blah': 'hello'
};

var obj2 = obj1.clone();
delete obj1['blah'];

console.log(obj1);
 => {}

console.log(obj2);
 => {blah: 'hello'}

Without Object Clone:

var obj1 = {},
    obj2 = obj1;

console.log(obj1);
 => {}

console.log(obj2);
 => {}

obj1['blah'] = 'hello';

console.log(obj1);
 => {blah: 'hello'}

console.log(obj2);
 => {blah: 'hello'}

obj2['blah2'] = 'hello';

console.log(obj1);
 => {blah: 'hello', blah2: 'hello'}

console.log(obj2);
 => {blah: 'hello', blah2: 'hello'}

Something went wrong with that request. Please try again.