• support@answerspoint.com

Most elegant way to clone a JavaScript object

1506

I have an object x. I'd like to copy it as object y, such that changes to y do not modify x.

What's the most elegant way of doing this in JavaScript?

Edit: I realize that copying objects derived from built-in JavaScript objects will result in extra, unwanted properties. This isn't a problem, since I'm copying one of my own, literal-constructed objects.

0Answer


Your Answer

    Facebook Share        
       
  • asked 8 years ago
  • viewed 1506 times
  • active 8 years ago

Best Rated Questions