How can i store data in a global varible within a local scope? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can i store data in a global varible within a local scope?

JavaScript

12th Dec 2016, 11:36 AM
Jelili Abdullahi Alagunfon
Jelili Abdullahi Alagunfon - avatar
3 Answers
+ 2
You drop the var inside the function to make the local scope a global variable
14th Jan 2017, 5:03 AM
totoro
totoro - avatar
+ 2
....but I wouldn't do that because it'll fail in "strict mode" so you need to know what you are doing
14th Jan 2017, 5:24 AM
totoro
totoro - avatar
0
why you don't declare the global variabel outside the local scope ?
13th Dec 2016, 7:01 AM
Iyan Hanafi Van Tony
Iyan Hanafi Van Tony - avatar