+ 1

Define variables all at once or as called?

I am writing a canvas animation and was wondering. can I declare all my variables at the beginning of script or is it better to declare as they are called? pros and cons?

8th Jul 2018, 5:47 PM
Joshua Morgan
Joshua Morgan - avatar
3 Respuestas
+ 2
Declare variables where the code will be more readable. https://github.com/borislavvv00 chech my github acount to see how i do it.
8th Jul 2018, 5:52 PM
B K
+ 2
Don't declare all your variables at the beginning. This will make them global. Global variables are a no-no. Try to avoid them.
8th Jul 2018, 6:33 PM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar