Allows javascript objects to traverse

will there be any negative impact if I use the generator function to make the Object prototype traverable?
the code is as follows

Object.prototype[Symbol.iterator] = function* () {
  for(let value in this){
    yield this[value]
  }
}

in fact, the main question is what negative impact it will have, that is, why it is not recommended to modify it, rather than looking for alternatives

Apr.09,2022

it is recommended not to modify the prototype to understand lodash.js


it is better to use Map instead of


generally traverse objects. You can traverse the resulting keys array through Object.keys () .

it's just that the order of the keys fetched each time may be inconsistent, because the key-value pair itself is unordered.

The traversal of

Object is meaningless because Object is unordered.
you can use the Object.keys Object.values methods to get traversal results of keys and values, but the order returned after each execution is not certain, but the key values correspond.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b40160-2c4da.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b40160-2c4da.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?