请教一下这个JavaScript的继承问题
PHPz
PHPz 2017-04-11 11:52:06
0
1
521

将函数的继承封装成如下函数:

function extend(child, parent){
    var f = function(){}
    f.prototype = parent.prototype
    child.prototype = new f()
    child.prototype.constructor = child
    child.uber = parent.prototype
}

function Creature(){}
function Person(){}

extend(Person, Creature)

请教一下,这是访问Person.uber属性,为什么是undefined?

PHPz
PHPz

学习是最好的投资!

reply all(1)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!