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

  • SEARCH
  • Home
  • 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 8628295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:30:05+00:00 2026-06-12T08:30:05+00:00

Possible Duplicate: List of global user defined functions in JavaScript? I have a java

  • 0

Possible Duplicate:
List of global user defined functions in JavaScript?

I have a java script file (.js) which contains some functions:

function func1(arg)
{
}

function func2(arg)
{
}

...

I want to enumerate all functions defined in js file.
Is there a root object in javascript to enum all sub objects by it? (by methods defined in this post)

Ugly solutions:

One approach is to define an array like:
var functions = [func1, func2, …];

Another approach is string processing (such as regular expressions):

/function.+(.+)/

I there better solution for it?
thanks.

  • 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-12T08:30:07+00:00Added an answer on June 12, 2026 at 8:30 am

    JavaScript has a root object, just open a console and type this, or window for that matter. If you want to list all functions in the global object, just treat the global object as you would any object:

    for (var property in this)
    {
        if (this.hasOwnProperty(property) && typeof this[property] === 'function')
        {
            console.log(property + ' is a function');
        }
    }
    

    You could leave out the .hasOwnProperty check, but remember that all objects, including window can be traced back to the Object.prototype, so you might end up enumerating prototype-methods, too. What’s more, the global object has its own prototype, too: Window.prototype.
    A word of warning: when it comes to X-browser issues, the global object is one of the worst objects to deal with. IE, Mozilla, Chrome, Opera and Safari all have differences between them, some more then others.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Randomize a List<T> in C# I have a list which contains many
Possible Duplicate: How to convert List<Integer> to int[] in Java? I have an ArrayList
Possible Duplicate: Replace individual list elements in Haskell? I have managed to make some
Possible Duplicate: What does jQuery.fn mean? I have some script on a page trying
Possible Duplicate: Java - Distinct List of Objects i have a sorted array of
Possible Duplicate: Global variables in Java How to create a list of global variables
Possible Duplicate: List all commits for a specific file I have a very deep
Possible Duplicate: nullPointerException in multi column list I have following app which fetches data
Possible Duplicate: list.clear() vs list = new ArrayList<int>(); I have a list: List<Integer> l1
Possible Duplicate: Concatenating a C# List of byte[] I have a list of byte[]

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.