Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "_" as prefix for all global variables and do not pass them around as function arguments #45

Open
icyflame opened this issue Dec 19, 2017 · 4 comments

Comments

@icyflame
Copy link
Owner

No description provided.

@Saurabh3333
Copy link
Contributor

Saurabh3333 commented Dec 19, 2017

do not pass them around as function arguments means we can't use global variables as arguments?

@icyflame
Copy link
Owner Author

@Saurabh3333 Yes.

@Saurabh3333
Copy link
Contributor

Sir, what is the problem with passing the global variables as function arguments?

@icyflame
Copy link
Owner Author

icyflame commented Jan 7, 2018

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants