Skip to content

Instantly share code, notes, and snippets.

@brittanmcg
Created October 7, 2015 22:13
Show Gist options
  • Save brittanmcg/f26134cb49d6cf73735c to your computer and use it in GitHub Desktop.
Save brittanmcg/f26134cb49d6cf73735c to your computer and use it in GitHub Desktop.
object with some values as objects
var obj = {
name: "Simon",
age: "20",
clothing: {
style: "simple",
isDouche: false
}
}
@arcin
Copy link

arcin commented Oct 8, 2015

@elreimundo Thanks for clearing up those issues! I totally forgot to change thing to deepCopy when I renamed the function haha. @konamax123 Copying in JS is rough because there are a lot of subtleties to consider when duplicating the memory allocated to objects and their contents. If you want a solution free of headaches (for the most part) consider Immutable data structures. They use structural sharing so creating "copies" isn't really that expensive. A good library is Facebooks ImmutableJS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment