1.
function p0(){
this.name = "p0";
this.colors = ["pink","black","gray"];}
function children0(){
p0.call( this );
this.type = "children0";}
new children0().name; // p0
new children0().colors; // ["pink","black","gray"]
p0.prototype.sex = "
p0.prototype.say = function() {
console.log(" hellow");}
new children0().sex; // undefined
// Uncaught TypeError: (intermediate value).say is not a function
new children0().say();
2.
function p1(){
this.name = "p1";
this.colors = ["red","blue","yellow"];
}function Children1(){
this.name = "Children1";}
Children1.prototype = new p1();
p1.prototype.sex = "
p1.prototype.say = function() {
console.log(" hellow! ");}
new Children1().sex; //
new Children1().say(); //hellow!
var s1 = new Children1();
s1.colors.push("black");
var s2 = new Children1();
s1.colors; // (4) ["red", "blue", "yellow", "balck"]
s2.colors; // (4) ["red", "blue", "yellow", "balck"]
3.
function p2(){
this.name = "p2";
this.colors = ["red","blue","yellow"];}
function Children2(){
p2.call(this);
this.type = "Children2";}
Children2.prototype = new p2()
var s1 = new Children2();
s1.colors.push("black");
var s2 = new Children2();
s1.colors; // (4) ["red", "blue", "yellow", "balck"]
s2.colors; // (3) ["red", "blue", "yellow"]
function p3(){
this.name = "p3";
this.colors = ["red","blue","yellow"];}
p3.prototype.sex = "
p3.prototype.say = function(){console.log("Oh, My God
function Children3(){
p3.call(this);
this.type = "Children3";}
Children3.prototype = p3.prototype;
var s1 = new Children3();
var s2 = new Children3();
console.log(s1, s2);
console.log(s1 instanceof Child3); // true
console.log(s1 instanceof Parent3); // true
console.log(s1.constructor.name); // p3
function p4(){
this.name = "p4";
this.colors = ["red","blue","yellow"];}
p4.prototype.sex = "
p4.prototype.say = function(){console.log("Oh, My God
function Children4(){
p4.call(this);
this.type = "Children4";}
Children4.prototype=Object.create(p4.prototyp
Children4.prototype.constructor = Children4;
Object.create
var p = {name: "p"}
var obj = Object.create(p)
// Object.create({ name: "p" })