function Person(name){
this.name=name;
this.age=function(age){alert(this.name+'现在'+age+'岁了!');};
this.action={
'eat':function(something){alert(name+'正在吃'+something)},
'look':function(something){alert(name+'正在看'+something)},
'run':function(){alert(this.name+'能跑!');}
};
}
var person=new Person('小明');
alert(person.age(10));
囧
你第一个 alert 是 person.age 里的 alert
第二个 alert 是你调用的
alert(person.age(10))
undefined 是因为 js 函数你不主动 return ,默认
return undefined
也就是说 person.age(10) 返回的是 undefined...╮(╯_╰)╭
上面这段代码只弹了一下
不过 'run':function(){alert(this.name+'能跑!');}
this.name 应该是拿不到的