About 28,300,000 results
Open links in new tab
  1. javascript - What is the difference between "let" and "var"? - Stack ...

    Apr 18, 2009 · 338 What's the difference between let and var? A variable defined using a var statement is known throughout the function it is defined in, from the start of the function. (*) A …

  2. JavaScript OR (||) variable assignment explanation

    That is, JavaScript "short-circuits" the evaluation of Boolean operators and will return the value associated with either the first non-false variable value or whatever the last variable contains.

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

  4. What does 'var that = this;' mean in JavaScript? - Stack Overflow

    Feb 3, 2011 · In a JavaScript file I saw: function Somefunction(){ var that = this; ... } What is the purpose of declaring that and assigning this this to it?

  5. "var" or no "var" in JavaScript's "for-in" loop? - Stack Overflow

    Apr 19, 2011 · But, coming from Java, putting the var inside the for head looks like it's local in the for loop, which it isn't. Hence, I prefer user422039's style below.

  6. setting a javascript variable with an if statement -- should the 'var ...

    var B = (A ==="red") ? "hot":"cool"; Ternary expressions will always return the first value if true, the second value if not. Great for one-off if/else statements, but if you get into more nested …

  7. When to use var in Javascript - Stack Overflow

    When you use var , you are instantiating a variable in the current scope. This will also prevent access of variables named the same in higher scope, within the current scope. In your first …

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

    Feb 6, 2009 · var values = typeof variable !== 'undefined' ? variable : ''; Also this will be helpful, when you try to declare the Global variable with instance assignment of the reference variable. …

  9. How can I check for "undefined" in JavaScript? - Stack Overflow

    The in operator checks for the existence of a property, regardless of its value, while the question at least appears to be asking how to test if the value of a variable is undefined. Perhaps a …

  10. When should you use "var", "let", or "const" in JavaScript code

    Apr 13, 2023 · Closed 2 years ago. New to JavaScript and a beginner. I came across JavaScript variables and realized there are three different ways to go about them (var, let and const). Do …