如何检查以查看正在访问的对象,从而有效地创建动态设置器?
我想做这样的事情:
var People = {};
// ...some code to change accessor on People...
var greeting = People.StevenSpielberg;
alert(greeting); // "Hi StevenSpielberg!"
我可能写的伪代码是:
People[name] = function(name) { return "Hi " + name; }
有任何想法吗?