14-new和this

 1 <!DOCTYPE html>
 2 <html>
 3 <head lang="en">
 4     <meta charset="UTF-8">
 5     <title></title>
 6 </head>
 7 <body>
 8 <script>
 9     //this
10 //    一、this只出现在函数中。
11 //    二、谁调用函数,this就指的是谁。
12 //    三、new People();   People中的this代指被创建的对象实例。
13 
14 
15 //    var aaa = new Object();
16     //new
17 //1.开辟内存空间,存储新创建的对象( new Object() )
18 //2.把this设置为当前对象
19 //3.执行内部代码,设置对象属性和方法
20 //4.返回新创建的对象
21 
22     var aaa = new stu();
23     console.log(aaa);
24     aaa.say();
25 
26     function stu(){
27         this.say = function () {
28             console.log(this);
29         }
30     }
31 
32 
33 </script>
34 </body>
35 </html>
原文地址:https://www.cnblogs.com/BingBing-Deng/p/10267122.html