ExamVeda
Login
Home
21
The maximum number of global symbols a module can define is
Discuss
Answer & Solution
Answer: Option C
Solution:
Generally, the various modules are allowed to run in the pristine (or near pristine) environment that it expects. The modules should minimize the number of global symbols they define – ideally, no module should define more than one.
22
To define each of the set classes as a property of the sets object (namespace) for the module, the statement is
Discuss
Answer & Solution
Answer: Option B
Solution:
The sets object is the namespace for the module, and we define each of the set classes as a property of this object.
23
Consider the following statement
var Set = sets.Set;
var s = new Set(1,2,3);
What could be the efficiency quotient of the above two statements ?
Discuss
Answer & Solution
Answer: Option A
Solution:
A programmer can import frequently used values into the global namespace. A programmer who was going to make frequent use of the Set class from the sets namespace might import the class like that.
24
The scope of a function is also called as
Discuss
Answer & Solution
Answer: Option B
Solution:
The scope of a function can be used as a private namespace for a module. Therefore, the scope of a function is called a module function.
25
Modules that have more than one item in their API can
Discuss
Answer & Solution
Answer: Option C
Solution:
Modules that have more than one item in their API can return a namespace object.
26
The provides() function and the exportsobject are used to
Discuss
Answer & Solution
Answer: Option A
Solution:
Frameworks that define module loading systems may have other methods of exporting a module’s API. There may be a provides() function for modules to register their API, or an exports object into which modules must store their API.
27
Consider the following code snippet
var sets = com.davidflanagan.collections.sets;
What is the programmer trying to do in the above code snippet?
Discuss
Answer & Solution
Answer: Option D
Solution:
Rather than importing individual classes, a programmer might import the entire module to the global namespace.
28
The properties() method is a
Discuss
Answer & Solution
Answer: Option B
Solution:
The properties() method is a non-enumerable method.
29
What can be done in order to avoid creation of global variables in JavaScript?
Discuss
Answer & Solution
Answer: Option C
Solution:
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).
30
The ‘$’ present in the RegExp object is called a
Discuss
Answer & Solution
Answer: Option C
Solution:
The ‘S’ is a special metacharacter that matches the end of a string.