在JavaScript中创建对象
function Person() {
this.name;
this.age;
this.sex;
this.show=function () {
console.log(this.name +":"+ this.age +":"+ this.sex)
}
}
var person = new Person();
person.name = "阿强";
person.age = 18;
person.sex = "男";
person.show();
var stu = new Object();
stu.name = "阿秀";
stu.age = 16;
stu.sex = "女";
console.log(stu.name+":"+stu.age+":"+stu.sex);
//JSON
var stus = {name:"阿丽", age:19, sex :"女"};
//打印stus对象的各个属性
console.log(stus.name + ":" +stus.age +":"+stus.sex);
console.log(stus);