5.8
1472 ワード
var object = {
'0' : 'A',
'1' : 'B',
'2' : function() {
alert("this");
}
}
for (var temp in object) {
alert(temp + ":" + object[temp]);
}
var luxun= {
'name' : 'luxun',
'sex' : 'man',
'eat' : function() {
alert("eating");
}
}
for (var temp in luxun) {
alert(temp + ":" + luxun[temp]);
}
function Base(name) {
this.name = name;
this.getName = function() {
return this.name;
}
}
function Child(id) {
this.id = id;
this.getId = function() {
return this.id;
}
}
Child.prototype = new Base("tom");//
var c1 = new Child(1);
alert(c1.getName());
var jack = {
name : "jack",
age : 30
}
var rose= {
name : "rose",
age : 29
}
function printName() {
return this.name;
}
alert(printName.call(jack));
this.addr = addr || new Address(null, null);
this.addr = addr || {};//no one
setName.apply(jack, ["Jack 1."]);
setName.call(rose, "rose 2");