1.

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)The question was posed to me in quiz.My query is from Augmentation of Classes in division Classes and Modules in JavaScript of JavaScript

Answer»

The CORRECT answer is (b) HTMLElement.prototype

To explain I would say: 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.



Discussion

No Comment Found

Related InterviewSolutions