Last active
December 26, 2020 11:12
-
-
Save rajatjain-21/4cf60fbfbe285164c56de05e8c9ac3ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let obj = { | |
a: 32, | |
b: 34 | |
} | |
Object.defineProperty(obj, Symbol.iterator, { | |
configurable: false, | |
enumerable: false, | |
writable: false, | |
value: function() { | |
let _this = this; | |
let idx = 0; | |
let objkeys = Object.keys(_this); | |
return { | |
next: () => { | |
return { | |
value: _this[objkeys[idx++]], | |
done: (idx > objkeys.length) | |
}; | |
} | |
} | |
} | |
}); | |
for (let val of obj) { | |
console.log(val); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment