Linked Questions
65 questions linked to/from Difference between variable declaration syntaxes in Javascript (including global variables)?
1
vote
1
answer
1k
views
What JS scope is used by <script> tag? [duplicate]
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
difference between var someVariable in Global scope and window["someVariable"] in JavaScript [duplicate]
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
What does `var` do in the global scope? [duplicate]
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;
</...
0
votes
0
answers
30
views
Assigning value to declared variable vs. assigning variable to non-declared variable? [duplicate]
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
Terminology question about global variables and global scope [duplicate]
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) ...
690
votes
17
answers
1.6m
views
Define a global variable in a JavaScript function
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
Passing parameters to JavaScript files
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
window.variableName
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
Redeclared javascript global variable overrides old value in IE
(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
Trying to Dynamically set a templateUrl in controller based on constant
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
How to make a variable which is inside a function global?
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 ...
2
votes
2
answers
3k
views
Javascript function works in FF, Opera etc, fails in IE8 - how to fix
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
Dojo 1.8 - create global variable in require
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
accessing a variable from window object in IE8 does not work
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 ...
1
vote
4
answers
5k
views
ie7 script error line 0 char 0 code 0 jquery 1.10.1
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
user1668414