Assuming we/the user(s) use latest browser.
For instance, if we have this object:
And we want to clone it and make it editable without affecting the original object, so DO NOT DO THIS:
Because every time the original object changes, the "new_object_clone" variable will also change, and vice versa.
We need to construct new object and copy the keys / values into it.
Just like copying array. But, array has built-in function, that is the
Here goes for cloning object...
How to use it
#2 Using new feature,
Why the "assuming"?
Because olden browsers don't support, either the
Object.keys new function, or the
Object.assign, or the
Using jQuery, it's more "polyfill-ed", can accommodate olden browser too. Check out this answer on Stack Overflow