DEV Community

Discussion on: Best way to copy an object in JavaScript?

Collapse
 
ptasker profile image
Peter Tasker

Good to see I'm not crazy! JSON.parse( JSON.stringify( obj ) ); seems to be a common 'shortcut'. But assigning each prop to a new object with obj.hasOwnProperty(item) also looks like a good option if you know which properties to look for.