JavaScript对象:动态处理访问者?

时间:2012-11-07 22:47:35

标签: javascript v8 accessor

如何查看正在访问的对象,有效创建动态setter?

我想做这样的事情:

var People = {};
// ...some code to change accessor on People...
var greeting = People.StevenSpielberg;
alert(greeting); // "Hi StevenSpielberg!"

我写的伪代码将是:

People[name] = function(name) { return "Hi " + name; }

有什么想法吗?

0 个答案:

没有答案