![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to minimize the use of global variables in JavaScript?
A global variable has global scope which means it can be defined anywhere in your JavaScript code. To minimize the usage of global variables, use consistent variables around different parts of your project.
var myValue = { common: function(){ //Add code }, val1: { myVar1: "Demo String One", func1: function(){ //Add some code }, } val2: { myVar1: "Demo String Two", func1: function(){ //Add another code }, } val3: { myVar1: "Demo String Three", func1: function(){ //Add another code here } } };
Advertisements