After rewriting the prototype object, why does the original prototype object still exist

        function Person(){}
        var friend=new Person();
        console.log(Person.prototype);            
        Person.prototype={                        
            constructor:Person,
            name:"ytf",
            age:"20",
            job:"student",
            sayName:function(){
                console.log(this.name);
            }
        }
        console.log(Person.prototype);
        console.log(friend.sayName());

clipboard.png

May.05,2021

because of the object you created first, the old prototype chain has been established.

var p_old = {};
function Person(){}
Person.prototype = p_old; // Person.prototype 

//var friend=new Person(); 
var friend = {};
friend.__porto__= Person.prototype // p_old;
Person.call(friend);

// Person.prototype 
Person.prototype = {
    //...
}

// friend.__porto__  p_old
console.log(friend.__porto__ == p_old) //true
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e54a0c-452d2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e54a0c-452d2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?