function Father(name,age) { this.name = name; this.age = age; if (typeof Father._initialized == "undefined") { Father.prototype.showname = function () { document.writeln("My name is " + this.name); }; Father.prototype.sex="male"; Father._initialized = true; } } function Son(name, age, girlfriend) { Father.apply(this, arguments); this.girlfriend = girlfriend; Son.prototype = new Father(); } var son = new Son("shiy", 7, false); son.showname(); //will make mistake var x=new Son("shilf",23,false) x.showname(); //it is right
var son = new Son("shiy", 7, false); son.showname(); //will make mistake var x=new Son("shilf",23,false) x.showname();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)