let people = {
name:["a","b","c","d"],
/*
getName:function(){
return function(){
var i=Math.floor(Math.random()*4);
return {
//this 指代的是getName 不是people 引入lamdads即可
n:this.name[i]
}
}
}*/
getName:function(){
return ()=>{
var i=Math.floor(Math.random()*4);
return {
//this 指代的是getName 不是people 引入lamdads即可
n:this.name[i]
}
}
}
}
var myname = people.getName();
alert(myname().n);