JavaScript: Clone Object

By Xah Lee. Date:

Here's the best way to clone (deep copy) a object

// deep copy/clone a object

JSON.parse(JSON.stringify(myObj))

// this is the best way. fastest too

〔➤see JavaScript: JSON Methods

Object and Inheritance Topic

  1. JavaScript: Object System Overview
  2. JavaScript: What's Object?
  3. JavaScript: Prototype and Inheritance
  4. JavaScript: Creating Object
  5. JavaScript: Object Literal Expression {…}
  6. JavaScript: Creating Object with Object.create()
  7. JavaScript: Find Object's Prototype/Parent
  8. JavaScript: How to Create Object with Parent X?
  9. JavaScript: Prevent Adding/Deleting/Modifying Object Properties
  10. JavaScript: Determine Type of Object
  11. JavaScript: Primitive Types Object Wrapper
  12. JavaScript: Clone Object
  13. JavaScript: Test Equality of Objects
  14. JavaScript: Boolean() Constructor Object
Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.