//创建对象
var myData = new Object();
myData.name = "admin";
myData.password = "admin";
document.writeln("hello" + myData.name + ".");
document.writeln("Today is" + myData.password + ".")
//对象字面量
var myData = {
name: "admin",
password: "admin"
};
document.writeln("hello" + myData.name + ".");
document.writeln("Today is" + myData.password + ".")
//对象添加方法
var myData = {
name: "admin",
password: "admin",
admin: function () {
document.writeln("hello" + myData.name + ".");
document.writeln("Today is" + myData.password + ".")
}
};
myData.admin()
枚举对象属性 for...in语句
delete 能直接删除对象的方法 delete myData.name;
网友评论