<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>创建对象</title>
</head>
<body>
<script>
// 方法1:
function people(name, age) {
this._name = name;
this._age = age;
}
son = new people("wbcvef", 32);
document.write("name:" + son._name + ",age:" + son._age + "<br/>");
// 方法2:
people = new Object();
people.name = "eftrwf";
people.age = "30";
document.write("name:" + people.name + ",age:" + people.age + "<br/>");
// 方法3:
people = {name: "idfgawen", age: "30"};
document.write("name:" + people.name + ",age:" + people.age);
</script>
</body>
</html>
来源:CSDN
作者:KaWaniu
链接:https://blog.csdn.net/qq_41026669/article/details/104633192