Nice article. JSON.parse/JSON.stringify is definitely a clean and easy way to copy objects, however I think it is worth mentioning that it is possible to lose type information this way. A good example of this is with Dates. If your object contains dates, JSON.stringify will turn it into a string, and JSON.parse will not turn it back into a date.

If you have a simple object just containing just basic types, like strings and numbers, the json way may be easier, but for any more complex objects, the recursion method is the way to go.

Entrepreneur, Real Estate Investor, Programmer. On a never ending quest for knowledge.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store