js的构造函数和原型
2021-03-17 16:27
标签:div prototype alert type nes 构造 his nbsp 对象 1.构造函数创建对象 function Person(name,age,job) { 2.原型 function Person(name, age, job) { this.name = name; 3.继承 js的构造函数和原型 标签:div prototype alert type nes 构造 his nbsp 对象 原文地址:https://www.cnblogs.com/xiaoxinstart/p/12782813.html
this.name = name;
this.age = age;
this.job = job;
this.sayName = function () {
alert(this.name);
}
}
var person1 = new Person("cherry", 25, "Engineer");
person1.sayName();
this.age = age;
this.job = job;
}
Person.prototype.sayName = function () {
alert(this.name);
}
var person1 = new Person("cherry", 25, "Engineer");
person1.sayName();
this.name = name;
this.age = age;
this.job = job;
}
Person.prototype.sayName = function () {
alert(this.name);
}
function Chinese() {
Chinese.prototype = new Person("cherry", 25, "Egineer");//Chinese继承自Person
var chinese = new Chinese();
chinese.sayName();//chinese共享Person的function
上一篇:常见的WEB安全及防护
下一篇:HTTPS退场正确做法