0
How can I access a variable in another function
I have been trying to access a variable which resides in a function from another function but I haven't had any lucks with that. I tried declaring the variable outside the functions but it didn't workout. So I'm wondering if there's a way particularly of achieving this?
4 Antworten
+ 3
Sound like you asking about javascript scope.
https://www.w3schools.com/js/js_scope.asp
+ 2
Is there some code you share with us, as an example of what you are trying to accomplish?
+ 1
Please reference link below.
https://code.sololearn.com/Wgr1MnQUr4zj/#html
0
I know the scopes; global and local variables. The issue here is, when I declare a variable(locally) in a function is there any way I can access that variable in another function? I know when you declare a variable in a function, it is accessible to only that function and no any other. I tried declaring the variable and writing the statement outside the functions (globally) but the function couldn't access it.