In JavaScript, is it possible to move inner functions from one function into the global scope? I haven't yet found any straightforward way to do this.
function moveMethodsIntoGlobalScope(functionName){
//move all of functionName's methods into the global scope
//methodsToPutIntoGlobalScope should be used as the input for this function.
}
//I want all of the methods in this function to be moved into the global scope so that they can be called outside this function.
function methodsToPutInGlobalScope(){
function alertSomething(){
alert("This should be moved into the global scope, so that it can be called from outside the function that encloses it.");
}
function alertSomethingElse(){
alert("This should also be moved into the global scope.");
}
}
methodsToPutInGlobalScopean object instead of function and then you will be able to access functions inside it.methodsToPutInGlobalScopeonly have function declarations inside it, or is there more? For example, using eval could work, but might not be what you want if there are more than function declarations inside the function.