JavaScript Questions & Answers – Modules in JavaScript | JavaScript MCQs
Questions
1
The functions provide() and require() of Dojo toolkit and Google’s Closure library are used for ___________
Answer: declaring and loading modules
2
The maximum number of global symbols a module can define is ____________
Answer: 1
⭐ Make GKSeries Your Preferred Source on Google
Add GKSeries as Preferred Source
3
To define each of the set classes as a property of the sets object (namespace) for the module, the statement is
Answer: sets.SingletonSet = sets.AbstractEnumerableSet.extend(…);
4
What will be the efficiency quotient of the following JavaScript statements?
var Set = sets.Set; var s = new Set(1,2,3);
Answer: The programmer imports at once the frequently used values into the global namespace
6
Modules that have more than one item in their API can ________
Answer: Return a namespace object
7
The provides() function and the exportsobject are used to _________
Answer: Register the module’s API and Store their API
8
What could be achieved by running the JavaScript code snippet below?
var sets = com.davidflanagan.collections.sets;
Answer: Importing the entire module
10
What can be done in order to avoid the creation of global variables in JavaScript?
Answer: To use an object as its namespace



