<!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>
<script>
function User(name, age, sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
var xiaohong = new User("小紅", 11, "男");
console.log(xiaohong);
// 使用了new,第一步,创建另一个空白的对象{}
// 第二步,赋值,原来函数里面的this就指向了这个新建的{}
// 第三步,执行,之前函数要执行了
// 第四步,返回新对象,已经执行的结果
</script>
</body>
</html>