[Vuejs]-Using Object Assign to clear state

-1👍

In addition to the other answers:
Essentially this question is an indirect duplicate of Changes to object made with Object.assign mutates source object.

Object.assign is safe to use for a max of 2 levels of nesting.

For example Object.assign(myObj.firstProp, myDefaultObj.firstProp);

Taken from the MDN documentation:

Warning for Deep Clone For deep cloning, we need to use other
alternatives because Object.assign() copies property values. If the
source value is a reference to an object, it only copies that
reference value.

Leave a comment