1.

To define each of the set classes as a property of the sets object (namespace) for the module, the statement is(a) sets = sets.AbstractEnumerableSet.extend();(b) sets.SingletonSet = sets.AbstractEnumerableSet.extend(…);(c) sets.SingletonSet = sets.extend(…);(d) sets = sets.extend(…);This question was posed to me during a job interview.The origin of the question is Modules in JavaScript topic in portion Classes and Modules in JavaScript of JavaScript

Answer»

The correct answer is (b) sets.SingletonSet = sets.AbstractEnumerableSet.EXTEND(…);

To explain I would SAY: Singleton is an object which can only be instantiated once. The extend keyword is used in class declarations or class expressions to create a class which is a CHILD of another class. The sets object is the namespace for the module, and we define each of the set classes as a property of this object.



Discussion

No Comment Found

Related InterviewSolutions