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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:36:38+00:00 2026-05-17T01:36:38+00:00

Basically what I am after is this, var foo = ‘I am foo!’; alert(window[‘foo’]);

  • 0

Basically what I am after is this,

var foo = 'I am foo!';
alert(window['foo']);

// output = I am foo!

This does not work in a jQuery wrapper, I understand that it may be due to jQuery having renamed the window object or whatnot. If anyone has any inkling as to if this may be possible in a jQuery wrapper, I would appreciate the knowledge !

  • 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-17T01:36:39+00:00Added an answer on May 17, 2026 at 1:36 am
    foo = "I am foo!";
    

    If you have a function scope around your var line, it’ll define it as a local variable instead of a global variable. It’s not jQuery “renaming the window object” or anything silly like that, it’s just how var works. I’d personally doing

    window.foo = "I am foo!";
    // or
    window["foo"] = "I am foo!";
    

    though, to make it explicit you wanted to define a global variable. Or use a comment to say that.

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

Sidebar

Related Questions

I have a loop which basically calls this every few seconds (after the timeout):
Scala Newbie alert: basically I'm trying to do something like this: where I pattern
Hi I have this code below which basically after 25 seconds of showing the
http://jsfiddle.net/cYmxB/ $('.change').click(function() { $('.link').each(function(e) { var color = this.className.match(/color-\w+/gi); alert(color); }); });​ I'd basically
Basically this is my function: function FillDivLeft(groups, side) { var cnt = 1; $.each(groups,
I am using this code to alter the title of an image. Basically it
So basically after you commit something on github and change a particular file, and
Basically I'm after advice on producing dynamic PDFs with charts, images and some styling
Basically I have a new client that is after the following functionality from her
I'd basically like to use reflection in Powershell, and after dynamically finding the methods

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.