JS: Iterable Interface
Object having Iterable Interface is called Iterable Object.
Iterable Interface Properties
Symbol.iterator
-
Symbol.iterator
is a Symbol.- Value must be a function.
- This function's return value must be an object that has Iterator Interface.
Example
array is iterable object.
Because it has inherited property key Symbol.iterator
.
const aa = [3, 4, 5]; // array has an inherited property key Symbol.iterator console.log(Reflect.has(aa, Symbol.iterator)); // not its own property console.log( aa.hasOwnProperty(Symbol.iterator) === false, ); // the property Symbol.iterator of array is inherited from Array.prototype console.log( Reflect.apply( Object.prototype.hasOwnProperty, Array.prototype, [Symbol.iterator], ), );