Does the Vue instance loses its old properties?

Viewed 73

Does the browser keep showing Vue instance properties even when they no longer exist? Because I've tried to set the instance to 4 making it a number but still the old data and methods don't disappear from the browser

var r = new Vue({
    el: "#test", //gets the element with id test
    data: {
        h2: "saned",
        ha: "<h3>this shit sucks</h3>",
        imgsrc: "image.jpg",
    }, //data section
    methods: {
        fun: function () {
            return "i am " + this.h2;
        },
    }, //functions section
});
r = 4; //the previous data won't dissapear

I want to understand how does it exactly work, because I've thought that since the object is no longer a Vue instance the previous instance data should disappear, I was hoping to put a pic showing how it stays, but I can't since it'll be a link anyway and the post won't be good.

1 Answers

Here you created the Vue instance and made r point to it:

var r = new Vue({})

Here you assigned a new value to r:

r=4;

Though you now have stopped r from pointing to it, the Vue instance itself stays untouched and hasn't been destroyed.

Related