<script>
   function Person(name,age){
     this.name=name;
     this.age=age;
     this.say=function(){
       console.log('你好,我是'+this.name)
     }
   }
  var lz=new Person('lz',12)
   console.log(lz)
    </script>

new做的四件事情

1.创建了一个新的对象

2.调用了这个函数

3.让函数中this指向这个新的对象

4.返回一个新的对象

posted on 2019-09-25 21:16  宅到深夜  阅读(363)  评论(0)    收藏  举报