127   JS

JS中原型链中的prototype与_proto_
 

    <script>
      function People(name) {
        this.name = name;
        this.sayName = function() {
          console.log('my name is:' + this.name);
        }
      }

      People.prototype.walk = function() {
        console.log(this.name + 'is walking');
      }

      var p1 = new People('饥人谷');
      var p2 = new People('前端');
    </script>
2404178-70684ddd20c13efb



Leave a Reply

Your email address will not be published. Required fields are marked *