1. var obj = {
    2. name: 'AAA',
    3. age: 23,
    4. address: '广州'
    5. }
    6. Object.defineProperty(obj, Symbol.iterator, {
    7. writable: false,
    8. enumerable: false,
    9. configurable: true,
    10. value: function() {
    11. var self = this;
    12. var index = 0;
    13. var keys = Object.keys(self);
    14. return {
    15. next: function() {
    16. return {
    17. value: self[keys[index++]],
    18. done: index > keys.length
    19. }
    20. }
    21. }
    22. }
    23. })
    24. for (const val of obj) {
    25. console.log(`属性值为:${val}`);
    26. }