Right now, I am in the process of creating a library system
In the code snippet below, there is a stringArray ['greet','name'] used as dependencies. The goal is to convert this stringArray into an array of functions and pass it into greetingToName() using apply(). Is there a method to achieve this conversion?
function greet(){
return 'hi!';
}
function name(){
return 'name';
}
function greetingToName (greet, name) {
console.log( greet() + ' ' + name() );
}
var stringArray = ['greet','name'];
greetingToName.apply(null, stringArray); // currently not functioning correctly, because it is passing 'greet' and 'name' as strings rather than function pointers.