// // class Company { constructor() { this._employees = []; } addEmployees(...names) { this._employees = this._employees.concat(names); } *[Symbol.iterator]() { for(let e of this._employees) yield e; } } let count = 0; let company = new Company(); company.addEmployees("Fred","Joe","Tommy","Tom", "Sophie"); for(let employee of company) { console.log(employee); }
No comments:
Post a Comment