构造函数的this是指向实例对象

<!DOCTYPE html> <html lang="en">
<head>     <meta charset="UTF-8">     <meta http-equiv="X-UA-Compatible" content="IE=edge">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>Document</title> </head>
<body>     <div></div>     <script>         function Star() {             this.name = '我是原型'             this.a = function() {                 console.log(this.name);                 console.log(this);             }         }         Star.prototype.sing = function() {             console.log('哈哈哈11');             console.log(this);         };
        var sss = new Star();         sss.name = '我是创建的';         sss.try = function() {             console.log(this.name);         }         sss.a();     </script> </body>
</html>
上一篇:3 分钟教你如何在 github 上精确的找开源项目?


下一篇:A star与RRT搜索的速度和效率对比,A satr和Rapidly Exploring Random Trees