zoukankan      html  css  js  c++  java
  • 试题

    写出输出值

    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);
  • 相关阅读:
    五 Servlet 技术
    二进制、八进制、十进制、十六进制之间怎样互相转换?
    HTML中怎样添加地图?
    特殊集合
    集合arraylist
    数组

    gif 命令大全
    for 循环与嵌套
    分支语句(switch case)
  • 原文地址:https://www.cnblogs.com/52css/p/3171479.html
Copyright © 2011-2022 走看看