Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8161211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:27:01+00:00 2026-06-06T18:27:01+00:00

For the following script, how can I write a function that returns all of

  • 0

For the following script, how can I write a function that returns all of the script’s functions as an array? I’d like to return an array of the functions defined in the script so that I can print a summary of every function that is defined in the script.

    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
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:27:02+00:00Added an answer on June 6, 2026 at 6:27 pm

    Declare it in a pseudo namespace, for example like this:

       var MyNamespace = function(){
        function getAllFunctions(){ 
          var myfunctions = [];
          for (var l in this){
            if (this.hasOwnProperty(l) && 
                this[l] instanceof Function &&
                !/myfunctions/i.test(l)){
              myfunctions.push(this[l]);
            }
          }
          return myfunctions;
         }
    
         function foo(){
            //method body goes here
         }
    
         function bar(){
             //method body goes here
         }
    
         function baz(){
             //method body goes here
         }
         return { getAllFunctions: getAllFunctions
                 ,foo: foo
                 ,bar: bar
                 ,baz: baz }; 
        }();
        //usage
        var allfns = MyNamespace.getAllFunctions();
        //=> allfns is now an array of functions. 
        //   You can run allfns[0]() for example
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Javascript can manipulate the document the browser is displaying, so the following: <script> document.write(<table><tr><td>Hola</td><td>Adios</td></tr></table>);
The following script returns 20 instead of 21! var d = new Date(2010/03/21); document.write(d.getDate());
I have the following function that returns only the 1st row of data and
I am learning C functions and trying to write a simple script that outputs
I'm trying to write a fabric function that puts a script on a remote
I'm trying to figure out if I can write an automatic script/function/event in SQL
I have a JavaScript function that returns a string. I want to write this
tl;dr Summary Write a function that—when registered to handle a specific event on multiple
I wonder whether someone can help me please. I'm using the following script to
it is the problem, i can't undertand anyway. i have the following simple script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.