javascript中创建对象的方式——原型方式 5
functionTeacher(){};Teacher.prototype.name="dana";Teacher.prototype.age=13;Teacher.pr...
function Teacher() {};
Teacher.prototype.name = "dana";
Teacher.prototype.age = 13;
Teacher.prototype.fav = ["足球", "篮球", "羽毛球"];
Teacher.prototype.learn = function() {
alert("诲人不倦");
};
这是源代码。
但是我写成了: function Teacher() {
Teacher.prototype.name = "dana";
Teacher.prototype.age = 13;
Teacher.prototype.fav = ["足球", "篮球", "羽毛球"];
Teacher.prototype.learn = function() {
alert("诲人不倦");
}
};
简单来说 就是原代码Teacher()为空,而我有代码。 展开
Teacher.prototype.name = "dana";
Teacher.prototype.age = 13;
Teacher.prototype.fav = ["足球", "篮球", "羽毛球"];
Teacher.prototype.learn = function() {
alert("诲人不倦");
};
这是源代码。
但是我写成了: function Teacher() {
Teacher.prototype.name = "dana";
Teacher.prototype.age = 13;
Teacher.prototype.fav = ["足球", "篮球", "羽毛球"];
Teacher.prototype.learn = function() {
alert("诲人不倦");
}
};
简单来说 就是原代码Teacher()为空,而我有代码。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询