What can be done in order to avoid creation of global variables in JavaScript?

What can be done in order to avoid creation of global variables in JavaScript? Correct Answer To use an object as its namespace

One way for a module to avoid the creation of global variables is to use an object as its namespace. Instead of defining global functions and variables, it stores the functions and values as properties of an object (which may be referenced to a global variable).

Related Questions

Which is the function in JavaScript that will print the current page in JavaScript?
(i) What is global warming? How global warming affects the rapid change of climate? (ii) What are the bad impacts of climate change? (iii) How climate change affects the environment of Bangladesh (iv) How global warming can be minimized (v) What should be the role of students to protect the environment.
What will be done if more than one page requires a file of JavaScript code?
Which are usually variables that are used internally in object methods and also are globally visible variables?
Which of the following global variables is used to get parameters?
Where can a JavaScript code be placed in an html page?