cli-cube-timer
cli-cube-timer copied to clipboard
Use "_" as prefix for all global variables and do not pass them around as function arguments
do not pass them around as function arguments means we can't use global variables as arguments?
@Saurabh3333 Yes.
Sir, what is the problem with passing the global variables as function arguments?
@Saurabh3333 it's not a good practice. Global variables are available everywhere in JavaScript, they needn't be passed around as function arguments. It also makes following the code harder for anyone who hasn't worked with JavaScript before. Questions like "If the variable is available everywhere, why is it being passed as a function argument? Is there some reason I am missing?"
It's messy, of course. I shouldn't have used global variables in the beginning, when I was designing this module. I ended up using them. So, I think the second best option, after completely refactoring index.js, is to embrace the fact that index.js has global variables!