function createObject(name,age){ var obj =new Object(); obj.name = name; obj.age = age; obj.run = function(){ return this.name + "---"+this.age; } obj.say = function(){ return "今天"; } return obj;// 这里不明白, 如果不return,alert不会执行 }
var box1 = createObject("张三",18); alert(box1.name);
业余奶茶品鉴师
相关分类