<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
//new 关键字执行过程
//1.new 构造函数可以在内存中创建一个空的对象
//2.让 this 就会指向刚刚创建的空对象
//3.执行构造函数里面的代码 给这个对象添加属性和方法
//4.返回这个对象
function Star(uname, age, sex) {
this.name = unmae;
this.age = age;
this.sex = sex;
this.sing = function (song) {
console.log(song);
}
}
console.log(ldh);
</script>
</head>
<body>
</body>
</html>
2021-07-24 JavaScript new 关键字执行过程
最新推荐文章于 2022-09-05 11:28:47 发布