JS能实现多态吗?怎么实现?用什么方法?
function Person() {
this.hi = function(){}
}
function One() {}
One.prototype = new People();
One.prototype.hi = function() {
return "This is one"
}
function Two() {}
Two.prototype = new People();
Two.prototype.hi = function() {
return "This is two"
}
var o = new One();
if(o instanceof People) {
alert("hihi, o from People")
}
JS是伪对象
课程中有说JS是面向对象编程语言吗?JavaScript是一门基于对象由事件触发的脚本语言。