Create a cheap clone of Object – Vue

Here's an obvious bit of code (obvious when you know about it) 🤦🏻‍♂️

How to create a clone of a Vue object without the bindings?

The snippet is not really about Vue but that's where I needed it

JSON.parse( JSON.stringify( myObject ) );Code language: JavaScript (javascript)

For a Vue option, I have read about the extend util but didn't work out in my scenario.

Vue.util.extend( {}, this.myObject );Code language: CSS (css)

More information

Leave a Reply

Your email address will not be published. Required fields are marked *