<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>homework2</title>
</head>
<body>
<b>. Mountain: 从前有座山,山里有座庙;还有name,height(高度)
Temple: 庙里有个老和尚,有个小和尚,还有name,area(面积)
Monk: 和尚能挑水,讲故事,化缘;还有name,age,sex
</b>
<script>
function monk(name, age, sex, affair) {
this.name = name;
this.age = age;
this.sex = sex;
this.affair = ["carryWater", "tellStory", "begForAlms"];
}
var Mountain = {
Temple: function() {
var Temple = {};
Temple.name = "庙";
Temple.area = "100平方";
Temple.monkOld = new monk("老和尚", "44", "男");
Temple.monkYoung = new monk("小和尚", "10", "男");
return Temple;
},
name: "花果山",
height: 200,
old:new monk("老和尚", "44", "男")
}
console.log(Mountain)
console.log(Mountain.Temple())
</script>
</body>
</html>其实作为一只单身狗,现在觉得没对象的话,可以new一个~