如下代码,为什么xiaoming这个对象无法调用say这个方法?怎么写在里面就报错?
function Person(name) { this.name = name; this.prototype.say = function () { alert("大家好我是"+this.name); }; } var xiaoming = new Person("robot"); console.log(xiaoming.name); xiaoming.say();
相关分类