JS: Iterator (class)
(new in JS: ECMAScript 2025)
What is the iterator class
the iterator class is mainly designed for hosting the property Iterator.prototype, so that it can be the parent of all builtin Iterator Objects, so that any Iterable Object but isn't an array, can directly use methods like forEach, map, etc without needing to be converted to array first.
What is iterator-like object
Iterator is a constructor but connot be called
console.log(typeof Iterator); // function try { Iterator(); } catch (xerror) { console.log(xerror); } // TypeError: Constructor Iterator requires 'new' try { new Iterator(); } catch (xerror) { console.log(xerror); } // TypeError: Abstract class Iterator not directly constructable