引用 李松峰 老师的PPT

 

 1 var Person = function(living, age, gender) {
 2   this.living = living;
 3   this.age = age;
 4   this.gender = gender;  
 5 };
 6 
 7 Person.prototype.getGender = function(){
 8   return this.gender;
 9 };
10 
11 var child = new Person(true, 25, 'male');
12 
13 console.log (child.getGender()); // male
14 console.log (child.__proto__ === Person.prototype);//true
15 console.log (child.constructor === Person);//true

 

 

相关文章:

  • 2021-11-05
  • 2021-10-28
  • 2021-04-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2021-10-22
猜你喜欢
  • 2021-06-23
  • 2021-06-21
  • 2021-12-20
  • 2021-07-13
  • 2022-12-23
  • 2021-05-14
相关资源
相似解决方案