Contents

How can we make methods available on all objects?
a) Object.add(methods)
b) Object.methods(add)
c) Object.add.methods(…)
d) Object.prototype

d

Explanation: It is possible to add methods to Object.prototype, making them available on all objects. This is not recommended, however, because prior to ECMAScript5, there is no way to make these add-on methods non enumerable, and if you add properties to Object.prototype, those properties will be reported by all for/in loops.


What is the procedure to add methods to HTMLElement so that they will be inherited by the objects that represent the HTML tags in the current document?
a) HTMLElement.prototype(…)
b) HTMLElement.prototype
c) HTML.addmethods()
d) HTML.elements(add)

b

Explanation: It is implementation-dependent whether classes defined by the host environment (such as the web browser) can be augmented using Object.prototype. In many web browsers, for example, you can add methods to HTMLElement.prototype and those methods will be inherited by the objects that represent the HTML tags in the current document.


You can refresh the webpage in JavaScript by using…………
a) window.reload
b) location.reload
c) window.refresh               
d) page.refresh

b

Explanation: The reload method is used to reload the current file. User can reload the page from the server through location. Reload.


The scope of a function is also called as
a) Predefined function
b) Module function
c) Public function               
d) Private function

b

Explanation: 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.


Modules that have more than one item in their API can………
a) Assign itself to a global variable
b) Invoke another
 module of the same kind
c) Return a namespace object
d) Invoke another module of the same kind

c

Explanation: Namespace is a container for a set of identifiers, functions, methods and all that. It gives a level of direction to its contents so that it will be well distinguished and organized. Modules that have more than one item in their API can return a namespace object.


The provides() function and the exportsobject are used to _________
a) Register the module’s API and Store their API
b) Call the modules api
c) Store the module’s API
d) Register the modules api

a