Untitled
unknown
javascript
3 years ago
816 B
2
Indexable
Never
// Online Javascript Editor for free // Write, Edit and Run your Javascript code using JS Online Compiler let user = { minLength : 5, maxLength : 100, [Symbol.iterator]() { this.current = this.minLength; return this; }, next() { if (this.current <= this.maxLength) { return { done: false, value: this.current++ }; } else { return { done: true }; } } } // user[Symbol.iterator] = function () { // return { // current: this.minLength, // last: this.maxLength, // next() { // if (this.current <= this.last) { // return { done: false, value: this.current++ }; // } else { // return { done: true }; // } // } // }; // } for (let num of user) { alert(num); } console.log(user);