<分区>
我需要在 module.export
对象中调用一个函数,只知道它的 string
名称
module.exports = {
a : function() { console.log('a'); },
b : function() { console.log('b'); },
c : function() {
var fn; // string contain the name of the function to call ('a' or 'b' for example)
// How do I call `fn` programatically from here?
// something like `self[fn]()`
}
};