How to deep copy a custom object in JavaScript?
问题 I've been surfing around here a while and still haven't found an answer that worked for me. Is there any way to deep copy a non-plain object in JS? I've tried jQuery.extend(true, {}, this) but it only cloned some of it, the rest remained as a reference to another object. 回答1: Here are 3 different methods for copying objects. Each method has pros and cons, so read through and pick the best for your situation Object.assign method Use Object.assign , which "is used to copy the values of all