私はこのような機能を持っています。
function myfun(input1, input2, input3){
//
// Other codes which deals with input2 and input3 (irrelevant)
//
function a(){
console.log('func a');
}
function b(){
console.log('func b');
}
function c(){
console.log('func c');
}
function d(){
console.log('func d');
}
// input1 is an array
for(var i=0; i<input1.length; i++){
var name = input1[i];
name(); // Doesn't work as 'name' refers to a string;
this[name](); // Doesn't work;
// How can i execute the nested function whose name is stored in input array ?
}
}
myfun(['b','d'], 'foo', 'bar');
名前がinput1配列で指定されているネストされた関数を呼び出すにはどうすればよいですか?
ありがとうございました。