+ 1

how to make a local variable global javascript

plz answer, P.S. this is pure js

12th Jun 2020, 12:53 AM
jason jang
jason jang - avatar
6 Answers
+ 3
Declare your variable outside the function once and then use it in function var x; function ak(){ x = your code goes here }
12th Jun 2020, 12:57 AM
Ayush Kumar
Ayush Kumar - avatar
+ 3
You can't make a variable global if it is declared inside functional scope. You need to declare it in global scope and use inside functions. //If you want us to fix problem for you, please link code.
12th Jun 2020, 5:18 AM
Raj Chhatrala
Raj Chhatrala - avatar
12th Jun 2020, 1:06 AM
Kevin ★
+ 1
Or else just dont use var to declare variable inside the function it will automatically become global.
12th Jun 2020, 1:01 AM
Ayush Kumar
Ayush Kumar - avatar
0
plz answer!!! T-T
12th Jun 2020, 12:56 AM
jason jang
jason jang - avatar
0
i tried it and didn't work
12th Jun 2020, 12:57 AM
jason jang
jason jang - avatar