JS: Interface
(new in ECMAScript 2015)
What is JavaScript interface
An interface is a spec for a set of property keys and values .
- Any object that has all the properties as described by an interface's spec, is said to have (conform to) that interface.
- The property can be inherited property.
- By definition, many objects can have the same interface.
- By definition, a object can have many interfaces.
When a object confoms to interface X, we say that the object is “X object”. e.g. a object that conforms to the iterable interface is called “iterable object”.
There are 3 interfaces defined by the JavaScript spec:
Purpose of JavaScript Interface
JavaScript interface is the underlying mechanism for how Iterable Object works.
JavaScript. Iterable, Iterator
- JS: Iterable Object
- JS: for-of Loop
- JS: Array.from
- JS: Spread Operator (triple dots)
- JS: Iterator
- JS: Iterator.prototype
- JS: Generator
- JS: Generator Function (asterisk)
- JS: Interface
- JS: Iterable Interface
- JS: Iterator Interface
- JS: IteratorResult Interface
- JS: Test If Object is Iterable or Iterator 📜