试题

写出输出值

var name='window';

function WhoAmI()

{

    alert(this.name);

}



var myCat={name:'kitty'};

myCat.tellSelf=function()

{

    whoAmI();

};

myCat.WhoAmI=WhoAmI;



var myDog={name:'dog'};

myDog.WhoAmI=WhoAmI;



WhoAmI();

WhoAmI.call(myCat);

myCat.tellSelf();

myCat.WhoAmI();

myDog.WhoAmI.apply(mycat);
View Code
var name='window';

function WhoAmI()

{

    alert(this.name);

}



var myCat={name:'kitty'};

myCat.tellSelf=function()

{

    whoAmI();

};

myCat.WhoAmI=WhoAmI;



var myDog={name:'dog'};

myDog.WhoAmI=WhoAmI;



WhoAmI();

WhoAmI.call(myCat);

myCat.tellSelf();

myCat.WhoAmI();

myDog.WhoAmI.apply(mycat);

 

 

2、

var animal={name:'动物'};

function Cat()

{

    this.name='小猫';

}

Cat.prototype=animal;



var myCat=new Cat();



delete myCat.name;

alert(myCat.name);

myCat.name='小明';

alert(myCat.name);

delete myCat.name;

alert(myCat.name);

delete myCat.name;

alert(myCat.name);



delete animal.name;

alert(myCat.name);

animal.name='animal';

alert(myCat.name);
View Code
var animal={name:'动物'};

function Cat()

{

    this.name='小猫';

}

Cat.prototype=animal;



var myCat=new Cat();



delete myCat.name;

alert(myCat.name);

myCat.name='小明';

alert(myCat.name);

delete myCat.name;

alert(myCat.name);

delete myCat.name;

alert(myCat.name);



delete animal.name;

alert(myCat.name);

animal.name='animal';

alert(myCat.name);

 

你可能感兴趣的:(试题)