About 51 results
Open links in new tab
  1. How to declare a global variable in JavaScript - Stack Overflow

    Oct 15, 2020 · How can I declare a global variable in JavaScript? If this is the only application where you're going to use this variable, Felix's approach is excellent. However, if you're writing a jQuery …

  2. Define a global variable in a JavaScript function - Stack Overflow

    691 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.

  3. How to declare global var in javascript and HTML?

    Aug 10, 2010 · How to declare a variable, I think global, the way I declare in an html file and then use it in a js file (included by <script> tags)?

  4. Can global constants be declared in JavaScript? - Stack Overflow

    Nov 13, 2010 · Javascript doesn't really have the notion of a named constant, or an immutable property of an object. (Note that I'm not talking about ES5 here.) You can declare globals with a simple var …

  5. Using a global variable in JavaScript - Stack Overflow

    The problem is that you're declaring a new variable named number inside of the function. This new variable hides the global number variable, so the line number = 10 assigns only to this new local …

  6. javascript - How to declare a global variable in a .js file - Stack ...

    Jun 3, 2009 · The intent is explicit. The use of the var keyword can easily lead to declaring global vars that were intended to be local or vice versa. This sort of variable scoping is a point of confusion for a …

  7. How to create javascript globally accessible static variable?

    Sep 24, 2014 · I think this answer is work for my global variable problem. But using this we can't create a static variable across pages. Now I think create a static variable across pages in JavaScript is …

  8. javascript - What is the correct way to check if a global variable ...

    Went down a huge rabbit-hole after reading only the code in the answers here, and not the one in the question. If you want to write code that works on both Nodejs and the browser, this is the correct way …

  9. JavaScript: initialize global variable in function - Stack Overflow

    Jan 17, 2015 · 1 It's called scoping and hoisting. There are two types of scope in javascript, they are Global scope and Function scope.In javascript functions create their own scope. So your code is …

  10. Where do I declare global JavaScript variables in a web page?

    Nov 22, 2010 · Where do I need to place a snippet of JavaScript code that initializes a variable that must be visible to all code executed with the page? (For example, event handlers on elements will need to …