Codice:
function objTest(){
function myObj(){
this.name = "";
this.age = "";
}
myObj.prototype.setName = function(newName){
if(typeof newName != "undefined"){this.name = newName;}else{document.write("enter a valid name<br>")}
}
myObj.prototype.setAge = function(newAge){
this.age = newAge;
}
myObj.prototype.getName = function(){
return this.name;
}
myObj.prototype.getAge = function(){
return this.age;
}
var personInfo = new myObj();
personInfo.setName("shivi");
personInfo.setAge(28);
document.write("Your name is " + personInfo.getName() + " and your age is " + personInfo.getAge());
function girlName(){
myObj.call(this);
this.girlmode = "sexy";
}
girlName.prototype = new myObj();
girlName.prototype.constructor = girl;
girl.prototype.setGirlMode = function(girlmode){
this.girlmode = girlmode;
}
girl.prototype.getGirlMode = function(){
return this.girlmode;
}
var getnewgirlMode = new girl;
getnewgirlname.setGirlMode("hot");
document.write("girl mode is " + getnewgirlMode.getGirlMode());
}
ma non mi visualizza nulla come output perchè