About 360,000 results
Open links in new tab
  1. 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.

  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 a …

  3. What is the way of declaring an array in JavaScript?

    The first way described above does not do what it says it does. It actually creates an array of size 5 (all elements undefined), assigning it to the variable a, and then immediately throws that array …

  4. JavaScript check if variable exists (is defined/initialized)

    Feb 6, 2009 · If variable was not defined at all (for instance: external library which define global variable is not yet loaded - e.g. google maps), you can check this without break code execution …

  5. javascript - Declaring vs Initializing a variable? - Stack Overflow

    Jul 30, 2015 · A variable declaration (e.g., var foo) causes that variable to be created as soon as the "lexical environment" is instantiated. For example, if that variable were defined within a …

  6. Define local function in JavaScript: use var or not?

    May 8, 2013 · Long answer: Local variables in JavaScript, just like global variables in JavaScript, can be defined with or without var. Therefore, the function of the program will not be interfered …

  7. javascript - What is the purpose of the var keyword and when …

    Apr 13, 2012 · Since variable declaration creates property with the DontDelete flag, the difference between var x = 1 and x = 1 (when executed in global scope) is that the former one - variable …

  8. Javascript How to define multiple variables on a single line?

    177 If I want to condense code, what's the proper JavaScript "strict" way to define multiple javascript variables on a single line?

  9. javascript: define a variable if it doesn't exist

    Nov 11, 2015 · @pedz it doesn't matter because the 'var' keyword will make the variable inside the if get redefined even if it never enters the if block. JS doesn't have a "block level scope variable …

  10. javascript - ES6 class variable alternatives - Stack Overflow

    Mar 20, 2014 · Currently in ES5 many of us are using the following pattern in frameworks to create classes and class variables, which is comfy: // ES 5 FrameWork.Class({ variable: 'string', …