1.

Which exception does the Iterators throw from their next() method when there are no more values to iterate, that work on finite collections?(a) Exit Iteration(b) Abort Iteration(c) Abort(d) Stop IterationThe question was posed to me during an internship interview.This interesting question is from JavaScript Extensions in section Classes and Modules in JavaScript of JavaScript

Answer»

The correct answer is (d) Stop ITERATION

The best explanation: Iterators that work on finite COLLECTIONS throw Stop Iteration from their next() method when there are no more values to iterate. Stop Iteration is a property of the global object in JavaScript 1.7. Its value is an ordinary object (with no PROPERTIES of its own) that is reserved for this special purpose of TERMINATING iterations. Note, in PARTICULAR,that Stop Iteration is not a constructor function like TypeError() or RangeError().



Discussion

No Comment Found

Related InterviewSolutions