js题求答案
var student = new Object();
student.age = 18;
student["name"] = "zhang3";
student.showName = function(){
alert(alert(student.name);)
}
如果用JSON字符串定义这个对象,请完成下面代码:
var student = ________________________;
------解决方案--------------------var student = {
age:18,
'name':'zhang3',
'showName':function(){
alert(this.name);
}
};
------解决方案--------------------
var student = {
'age':18,
'name':'zhang3',
'showName':function(){
alert(this.name);
}
};