zoukankan      html  css  js  c++  java
  • __proto__、prototype、constructor 之间的关系

    引用 李松峰 老师的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
  • 相关阅读:
    mysql基础
    协程
    锁与队列
    线程练习
    线程
    并发编程
    进程
    操作系统发展史
    第六周----例行报告
    附加题找bug
  • 原文地址:https://www.cnblogs.com/qzsonline/p/2949819.html
Copyright © 2011-2022 走看看