0

what is a difference

what is a difference between 1 and 2: 1. function one(){ let ball = 10 } 2.function one(){ ball = 10 } and which situations we can use any of them (if there is a difference)

24th Jun 2020, 5:22 PM
medzvre gena
medzvre gena - avatar
2 Answers
+ 1
use 1 when you only want to use the variable in the function because it will not work anywhere else but use 2 when reassigning a globally scoped variable one which is not in a function then just gets reassigned in a function this variable is visible everywhere that is why it is called global scoping.
24th Jun 2020, 9:40 PM
moses
moses - avatar
0
Don't use 2 function at all.
24th Jun 2020, 11:21 PM
🇼🇳Vivek🇼🇳
🇼🇳Vivek🇼🇳 - avatar