日期:2014-05-16  浏览次数:20394 次

一个最基本的继承显示结果为undefined
JScript code

function person(name,age)
            {
                this.name=name;
                this.age=age;
                this.showInheritance=function()
                {
                    document.write(this.name+" "+this.age);
                }
            }
            function dog(name,age)
            {
                this.x=person;
                this.x(name.age);
            }
            var dog1=new dog("bage",3);
            dog1.showInheritance();

应该打印 bage 3才对啊

------解决方案--------------------
function dog(name,age)
{
this.x=person;
this.x(name,age);
}

------解决方案--------------------
JScript code
            function dog(name,age) {
                this.x=person;
                this.x(name, age); //刚才标注错了,你这里有低级错误,逗号写成点号了
            }