对象方法里要通过一个变量来调用显示对象属于名称,可以这样做
var person = {
borther1: { name: "tom" },
borther2: { name: "jack" },
borther3: { name: "david" },
sayBorther: function (num) {
return this["borther"+num]
}
}
var person =