0%

712_原型对象的this指向

<script>
      function Star(uname, age) {
        this.uname = uname;
        this.age = age;
      }

      var that;
      Star.prototype.sing = function () {
        console.log("我会唱歌");
        that = this;
      };

      //1、原型对象和构造函数里面的this指向的都是实例对象ldh
      console.log(that);
    </script>