0

Are Function Parameters Global?

If a variable is stored as a function parameter, can it be accessed outside of the function?

25th Sep 2018, 4:33 PM
Joshua Morgan
Joshua Morgan - avatar
6 ответов
+ 8
Make X a global var like: var x; function() { x = .... }
25th Sep 2018, 5:09 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 5
Can you show me an example of what you mean/need??
25th Sep 2018, 4:51 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 3
No, you can have a different variable with the same name on the outter scope though...
25th Sep 2018, 4:44 PM
Valen.H. ~
Valen.H. ~ - avatar
0
so I can make a var inside function assign to parameter, and then it is accessible?
25th Sep 2018, 4:46 PM
Joshua Morgan
Joshua Morgan - avatar
0
how to connect x to speed function gasPedal() { var x = null//pedal "depth" } function car(make,model,speed,etc){ if (gasPedal) { speed += x } }
25th Sep 2018, 5:06 PM
Joshua Morgan
Joshua Morgan - avatar
0
sorry, very rough, quick draft
25th Sep 2018, 5:06 PM
Joshua Morgan
Joshua Morgan - avatar