一、构造一个Person对象(相当于Java中的有参构造函数)function person(name, sex, age, addr, salary) { this.name = name; this.sex = sex; this.age = age; this.addr = addr; this.salary = salary;}二、对象实例隐式传递this指针person.prototype.func_pro=function () { console.log(this);};let Sakura =new person(“Sakura”,“女”,16,“FateStayNight”,10000000000);let Illyasviel= new person(“Illyasviel “,“女”,14,“FateStayNight”,9999999999);Sakura.func_pro();Illyasviel.func_pro();console.log(”——————————————————-” + “\n\n”);三、new 与 prototype1、总结:console.log(“new 与 prototype”);//1、let variable ={};//2、nodejs中每个对象都有一个__proto__属性// 建立两个对象之间的关联:// 一个对象可以使用__proto__关联另外一个对象// proto(对象的内部原型的引用): prototype(对象的原型) 浅拷贝// __proto__与prototype指向同一个对象的引用//3、 对象实例作为this指针的指向 传递给后面的函数//4、 调用这个函数2、可以通过prototype.key=value 来扩充对象Elffunction Elf(name) { this.name =name; console.log(“Elf\t”+name);}console.log(“可以通过prototype.key=value 来扩充对象Elf”);Elf.prototype.love=function () { console.log("%s love ‘DATE A LIVE!’", this.name);};let Yuzuru = new Elf(“Yuzuru”);let Kaguya = new Elf(“Kaguya”);Yuzuru.love();Kaguya.love();console.log("——————————————————-" + “\n\n”);3、 实例.proto 与 方法.prototype指向 同一个对象的引用console.log(“实例.proto 与 方法.prototype指向 同一个对象的引用”);console.log(Yuzuru.proto);console.log(Elf.prototype);console.log("——————————————————-" + “\n\n”);let func_data =function(){ console.log(“func_data”);};func_data.prototype.func_test=function(){ console.log(“func_test”,this);};// 实例.proto 与 方法.prototype指向 同一个对象的引用console.log(“实例.proto 与 方法.prototype指向 同一个对象的引用”);console.log(Yuzuru.proto);console.log(Elf.prototype);console.log("——————————————————-" + “\n\n”);let func_data =function(){ console.log(“func_data”);};func_data.prototype.func_test=function(){ console.log(“func_test”,this);};4、实例.proto 与 方法.prototype 分别属于2个不同的字典表{}console.log(“实例.proto 与 方法.prototype指向 分别属于2个不同的字典表{}”);let data =new func_data();data.name=“Innocence”;data.proto.func_test();data.func_test();console.log("——————————————————-" + “\n\n”);5、可以将对象实例看做为一张字典表//可以将data看做1张表console.log(“可以将data看做1张表”);//隐式调用thisdata.func_test();//显示调用this 将data作为this传递给data._proto_对象里的函数test_funcdata.proto.func_test.call(data);console.log("——————————————————-" + “\n\n”);6、调用取值的顺序data.func_test=function () { console.log(“new func_test”,this);};data.func_test();//data.key_func 首先会到对象实例的表里搜索是否有没有这样的key 若没有再到其__proto__里面搜索