function person(params) {
this.name = 213
this.lname = 'kk'
}
person.prototype.fname = 'k'
let temp = new person()
Object.prototype[Symbol.iterator] = function () {
let arr = Object.keys(this)
let index = 0
return {
next: () => {
let obj = {
value: this[arr[index]],
done: index >= arr.length
}
index++
return obj
}
}
}
Object.prototype[Symbol.iterator] = function* () {
let arr = Object.keys(this)
let index = 0
while(index<arr.length) {
let value=this[arr[index]]
index++
yield value
}
}
for (const iterator of temp) {
console.log(iterator);
}