<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="div1"></div>
</body>
<script type="text/javascript">
var div1 = document.getElementById("div1");
//获取到的元素是对象
var arr = new Array();
var str = new String();
var date = new Date();
//js的数据类型:
// 基本数据类型:number,string,bool,undefind,null;
// 复杂数据类型:object
var obj = new Object();
var obj = {
a:5,
b:10
};
// alert(obj.b);
//建立一个person对象,属性:名字,性别,年龄
//方法:吃饭,打架,购物
var Person = {
name:"kk",
sex:'男',
age:15,
chifan:function () {
console.log("吃饭");
},
dajia:function () {
console.log("打架");
},
gouwu:function () {
console.log("购物");
}
};
var person = new Object();
person.name = "lili";
person.age=18;
person.eat=function () {
alert("吃饭");
}
</script>
</html>
网友评论