Для следующего скрипта, как я могу написать функцию, которая возвращает все функции скрипта в виде массива? Я хотел бы вернуть массив функций, определенных в скрипте, чтобы я мог распечатать сводку каждой функции, определенной в скрипте.Возврат всех функций, определенных в файле 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
}
Чтобы уточнить, getAllFunctions() следует только повторно включите функции, определенные в самом скрипте, и ничего больше. –
Я уточнил исходный вопрос, чтобы вопрос уже не был двусмысленным. –
Посмотреть это сообщение http://stackoverflow.com/questions/493833/list-of-global-user-defined-functions-in-javascript – anazimok