About 378,000 results
Open links in new tab
  1. Define a global variable in a JavaScript function - Stack Overflow

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

  2. 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 …

  3. 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 …

  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 …

  5. 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)?

  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 …

  7. javascript - How do I change the value of a global variable inside …

    Jun 3, 2012 · I am using JavaScript and I create a global variable. I define it outside of a function and I want to change the global variable value from inside a function and use it from another …

  8. javascript - Why are global variables considered bad practice?

    Apr 10, 2016 · Secondly, global variables take longer for Javascript to "find" than local variables. The difference in speed isn't huge, but it does exist. For further reading and a more in-depth …

  9. What are global variables and 'window' variables in JavaScript?

    With JavaScript, the global scope is the complete JavaScript environment. In HTML, the global scope is the window object. All global variables belong to the window object. Your global …

  10. javascript - What is the correct way to define global variable in ES6 ...

    Apr 25, 2017 · I can't seem to find a description of the way I should export global variable from ES6 module. Is there a resource where it's defined? The only solution that seems to work is …