<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>

</style>
</head>

<body>
<div class="container">
</div>
<script>
//js对象创建
//方法1 {}、属性和方法键值对 用逗号分开
var person = {
name: "李卫国",
age: 12,
getm: function() {
console.log(3333333)
}
}
//方法2 new Object()
var obj = new Object()
obj.name = "张三"
obj.say = function() {
console.log('obj say')
}
//方法3 构造函数
function Person(name, age) {
this.name = name;
this.age = age;
this.sing = function(song) {
console.log(this.name + " sing" + song)
}
}
//js对象使用 属性调用:对象名.属性名 对象名['属性名'] 方法调用:对象名.方法名()
// console.log(person.name)
// console.log(person['name'])
// person.getm()
// console.log(obj.name)
// obj.say()
var zxy = new Person("张学友", 40)
//zxy.sing('一千个伤心的理由')
// for in 循环对象
for (let k in zxy) {
console.log(k) //属性k
console.log(zxy[k])
}
//
var myMath = {
pi: Math.PI,
max: function() {
var max = arguments[0]
for (var i = 1; i < arguments.length; i++) {
if (arguments[i] > max) {
max = arguments[i]
}
}
return max
},
min: function() {
var min = arguments[0]
for (var i = 1; i < arguments.length; i++) {
if (arguments[i] < min) {
min = arguments[i]
}
}
return min
}
}
console.log(myMath.pi)
console.log(myMath.max(23, 12, -12, 32, -43, 32))
console.log(myMath.min(23, 12, -12, 32, -43, 32))
</script>
</body>

</html>