0
Can i use a var of a function outside it?
Please help me Is un javascript
4 Antworten
+ 3
Yes.
Undeclared variable will become a property of window object.
https://code.sololearn.com/WwhKQUoMbXHH/?ref=app
https://www.sololearn.com/post/91113/?ref=app
+ 2
Victor Emmanuel
Global variables can be used anywhere in JavaScript even inside any function defined in same JavaScript.
Variables defined in any function can be accessed in that function, there is a way to access those variables outside function by passing as argument (parameter) to another function, from function where it's defined. It can be updated by assigning return value of another function call where variable is defined.
There is no other way to access variable defined in an function.
DHANANJAY PATEL
+ 1
You can't do it. You could only use it in the inside of the function.
0
You can declare a global variable like this:
var blankVar;
Then pass the information to the variable inside the function like this:
function passParameters() {
**some bit of code**
blankVar = **some bit of code**;
}