javascript继承对象冒充方式

来源:互联网 发布:ubuntu python3 pyqt5 编辑:程序博客网 时间:2024/05/17 05:59

function Parent(username)

{

this.username = username;

this.sayHello = function()

{

alert(username );

}

}


function Child(username,pwd)

{

this.method = Parent;

this.method (username);

delete this.method;

this.pwd = pwd;

this.sayWorld = function()

{

alert(pwd);

}

}


var p  = new Parent("zhangsan");

var c = new Child("zhangsan","123456");

p.sayHello();

c.sayHello();

c.sayWorld();


0 0
原创粉丝点击