ECMAScript提供的对象有:String、Date、Array、Boolean、Math、Number、RegExp、Global
程序中需要用到很多自定义的js对象
1、直接创建
var obj = new Object();
obj.username = "jinxiao";
obj.age = 26;
可替代该方法的是:var obj = {username:"jinxiao",age:26};
2、构造函数创建
function Obj(username,age){
this.username = username;
this.age = age;
}
var obj1 = new Obj("jinxiao",26);
var obj2 = new Obj("brotherxiao",27);
时间: 2024-10-13 11:13:05