Para el siguiente script, ¿cómo puedo escribir una función que devuelva todas las funciones del script como una matriz? Me gustaría devolver una serie de funciones definidas en el script para poder imprimir un resumen de cada función definida en el script.Devuelve todas las funciones que se definen en un archivo de Javascript
function getAllFunctions(){ //this is the function I'm trying to write
//return all the functions that are defined in the script where this
//function is defined.
//In this case, it would return this array of functions [foo, bar, baz,
//getAllFunctions], since these are the functions that are defined in this
//script.
}
function foo(){
//method body goes here
}
function bar(){
//method body goes here
}
function baz(){
//method body goes here
}
Para aclarar, getAllFunctions() solo debería volver activar las funciones que se definen en el script en sí, y nada más. –
Aclaré la pregunta original para que la pregunta ya no sea ambigua. –
Ver esta publicación http://stackoverflow.com/questions/493833/list-of-global-user-defined-functions-in-javascript – anazimok