Iterator Protocol:

The Iterator protocol defines an interface for objects that produce a sequence of values during iteration. An Iterator object must implement a next method that returns an object with two properties:

  • value (the next value in the sequence)
  • done (a Boolean indicating whether the iteration is complete).

The iterator protocol

the iterator protocol defines a standard way to produce a sequence of values (either finite or infinite), and potentially a return value when all values have been generated.

Getters Setters And Statics

Interfaces or objects consists mostly of methods, and sometimes you will need to create objects that holds non functional values. We have seen this with the map object which has methods such as size, which simply is there to tell you the numbers of keys on your object.

Getters

Getters, as the values implies, is a method that is used to get property from your object. A getter function must have 0 arguments.

  • A getter function is accessed like a property on the object, without the need of being called.

Setter

A setter, differently to a getter, is used to set a value in the object. instead of receiving a prop like a function would, you simply access the property and assign a value to it, in order to set the value.

Static

For static properties, they are properties that, rather than being shared across different instances, they are simply members of the class itself.

Instance of operator

The instance of operator is used to define whether something is an instance of a specific class This can be handy when you are trying to determine if a particular object is an instance of a X given constructor.