Linked Questions

1 vote
1 answer
1k views

I am writing in my html some JS between <script> tag: console.log('exist in ? scope', foo !== undefined) console.log('exist in window scope', window.foo !== undefined) console.log('exist in ...
-2 votes
1 answer
551 views

Possible Duplicate: Javascript global variables Should I use window.variable or var? Problem: Two ways to define global variables : var someVariable in global scope ; window["someVariable"] = "...
2 votes
2 answers
143 views

In an HTML <script> tag, outside of any function, does var have any meaning? Is there any difference between these three notations? <script> var a = 1; b = 1; window.c = 1; </...
AndreKR's user avatar
  • 34k
0 votes
0 answers
30 views

What is the diference between assigning value to declared variable and assigning value to non-declared variable ? I got a case where it have a difference. Go to chrome browser console and put this ...
0 votes
2 answers
43 views

Is the following true: For something to be in the global scope means it can be accessed anywhere in all files. All global variables have global scope. Therefore, the global object (and its properties) ...
tonitone115's user avatar
690 votes
17 answers
1.6m views

Is it possible to define a global variable in a JavaScript function? I want use the trailimage variable (declared in the makeObj function) in other functions. <html xmlns="http://www.w3.org/...
207 votes
20 answers
328k views

Often I will have a JavaScript file that I want to use which requires certain variables be defined in my web page. So the code is something like this: <script type="text/javascript" src="file.js"&...
79 votes
6 answers
174k views

I am going through some code and at the beginning of the script we have var emailID = email. Later on, the code refers to emailID by going window.emailID. I am wondering what are the rules that allow ...
Jon's user avatar
  • 2,409
10 votes
3 answers
8k views

(creating a separate question after comments on this: Javascript redeclared global variable overrides old value) I am creating a globally scoped variable using the square bracket notation and ...
6 votes
3 answers
13k views

I want to change the templateUrl associated with controller based on a preset constant that I've defined in my angularjs bootstrap. I can't figure out how to change that. I've experimented with ...
6 votes
7 answers
474 views

Following is my javascript function, I want to use variable selected outside function, but I am getting selected not defined error in console of inspect element. window.yourGlobalVariable is not ...
Ahmed Syed's user avatar
  • 1,199
2 votes
2 answers
3k views

I have the following function (worked in IE6 but is broken in IE8) function implode() { var str = ''; for(item in globvars) //<- IE8 wets itself here ... str+= '\n' + globvars[item]+';'...
5 votes
2 answers
8k views

I noticed that some of the legacy scripts that I'm working on for a project weren't working anymore after my team upgraded to Dojo 1.8. Specifically, the global variable that they created wasn't ...
4 votes
1 answer
4k views

I have the following script: xxx = 12232; for (var j in window) { if (j==='xxx') alert('hey'); } If I execute in Chrome or Firefox I get the alert-dialog printing 'hey'. If I execute in IE8 I ...
Zo72's user avatar
  • 15.5k
1 vote
4 answers
5k views

I'm adding some social share links to a site. In the HTML, I just have basic links like: <a class="facebook_share" href="https://www.facebook.com/sharer/sharer.php">Facebook</a> I'm using ...
user avatar

15 30 50 per page
1
2 3 4 5