简体   繁体   中英

Is there a way to iterate over an object without the use of Object.keys(), Object.values() and object.entries() classes?

This is the code I used, however, I keep getting syntax error.

function iterateOverObject(obj) {
  foreach (const value in obj[key, value]) {
  console.log(obj[value]);
}
}

Try this:

function iterateOverObject(obj) {
    for (const key in obj) {
    console.log(obj[key]);
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM