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 546075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:49:44+00:00 2026-05-13T10:49:44+00:00

Is there a way to get all variables that are currently in scope in

  • 0

Is there a way to get all variables that are currently in scope in javascript?

  • 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-05-13T10:49:44+00:00Added an answer on May 13, 2026 at 10:49 am

    No. “In scope” variables are determined by the “scope chain”, which is not accessible programmatically.

    For detail (quite a lot of it), check out the ECMAScript (JavaScript) specification. Here’s a link to the official page where you can download the canonical spec (a PDF), and here’s one to the official, linkable HTML version.

    Update based on your comment to Camsoft

    The variables in scope for your event function are determined by where you define your event function, not how they call it. But, you may find useful information about what’s available to your function via this and arguments by doing something along the lines of what KennyTM pointed out (for (var propName in ____)) since that will tell you what’s available on various objects provided to you (this and arguments; if you’re not sure what arguments they give you, you can find out via the arguments variable that’s implicitly defined for every function).

    So in addition to whatever’s in-scope because of where you define your function, you can find out what else is available by other means by doing:

    var n, arg, name;
    alert("typeof this = " + typeof this);
    for (name in this) {
        alert("this[" + name + "]=" + this[name]);
    }
    for (n = 0; n < arguments.length; ++n) {
        arg = arguments[n];
        alert("typeof arguments[" + n + "] = " + typeof arg);
        for (name in arg) {
            alert("arguments[" + n + "][" + name + "]=" + arg[name]);
        }
    }
    

    (You can expand on that to get more useful information.)

    Instead of that, though, I’d probably use a debugger like Chrome’s dev tools (even if you don’t normally use Chrome for development) or Firebug (even if you don’t normally use Firefox for development), or Dragonfly on Opera, or “F12 Developer Tools” on IE. And read through whatever JavaScript files they provide you. And beat them over the head for proper docs. 🙂

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

Sidebar

Related Questions

Is there a way to get a list of all the GMarkers that have
Is there a way to get all methods (private, privileged, or public) of a
Is there a way to get all alphabetic chars (A-Z) in an array in
Is there a way to get all versions of list item(s) using a CAML
Is there a way to get all the querystring name/value pairs into a collection?
Is there a way to get all possible values from a MySQL enum column?
In Java, is there any way to get (catch) all exceptions instead of catching
Is there a built in way to get all of the media files (movies
Is there a way in C# to: Get all the properties of a class
Is there a way I can ask Visual source safe to get all the

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.