blue_collar.prototype.age = "33";
blue_collar.prototype.say = function () (
alert ( "my name is" + this.name);
);
function city_blue_collar () (
)
city_blue_collar.prototype = new blue_collar ();
var jj = new city_blue_collar;
jj.say ();
Prototype chain also has a prototype chain Disadvantages: Can not pass parameters. In addition, the prototype chain does not support multiple inheritance, because
E. hybrid method
Ways to use the constructor Writing category of property, inheritance of property the use of call () or apply ()
Writing using a prototype approach to the method, the method of using the prototype chain to inherit
eg.1
function beauty (name, age) (
this.name = name;
this.age = age;
)
beauty.prototype.say = function () (
alert ( "my daughter called" + this.name);
);
function china_beauty (name, age, area) (
beauty.call (this, name, age);
this.area = area;
)
china_beauty.prototype = new beauty ();
china_beauty.prototype.from = function () (
alert ( "I come from the" + this.area);
);
var diaochan = new china_beauty ( "貂禅", "16", "Lintao");
diaochan.say ();
diaochan.from ();
alert (diaochan.age);







