阅读背景:

如何像对象一样使用`this`并通过字符串获取其变量/函数?

来源:互联网 

I've got an object.

我有一个对象。

function Obj()
{

}

Obj.prototype.doSomething = function(thing)
{
    this["do" + thing]();
}

Obj.prototype.doAlert = function()
{
    alert("Alert!");
}

var obj = new Obj();
obj.doSomething("Alert");
function Obj()



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: