You redeclare gsd
as a new variable inside your function. Remove var
in front of gsd
inside the function to address the gsd
in the outer scope.
More Related Contents:
- How do JavaScript closures work?
- What is the scope of variables in JavaScript?
- Define a global variable in a JavaScript function
- What is the scope of this JavaScript function
- I would like to ask how to explain this (javascript function)
- JavaScript check if variable exists (is defined/initialized)
- Function declarations inside if/else statements?
- Calling a JavaScript function named in a variable [duplicate]
- JavaScript check if variable exists (is defined/initialized)
- Set “this” variable easily?
- JavaScript loop variable scope
- Why is the variable `closed` being logged as `false`, if I define it globally as `0`?
- Variables set during $.getJSON function only accessible within function
- functions inside or outside jquery document ready
- javascript variable scope in the IF statement
- What happens when JavaScript variable name and function name is the same?
- Calling a Function defined inside another function in Javascript
- Use JavaScript variable as function name?
- Passing a local variable from one function to another
- Function not calling within an onclick event
- Setting onclick to use current value of variable in loop [duplicate]
- Javascript: Get access to local variable or variable in closure by its name [duplicate]
- JavaScript variable number of arguments to function
- Function in JavaScript that can be called only once
- What is the correct term for variable shadowing in JavaScript?
- Why doesn’t console.log work when passed as a parameter to forEach?
- Is there a better way of writing v = (v == 0 ? 1 : 0); [closed]
- javascript – document.write error?
- JavaScript Variable Scope [duplicate]
- Passing a global variable to a function