Referencing / Parsing an object

This question already has an answer here:

  • How to iterate over a JavaScript object? 11 answers
  • How to loop through a plain JavaScript object with the objects as members? 17 answers
  • How do I loop through or enumerate a JavaScript object? 29 answers
  • Iterate through object properties 24 answers
  • How to iterate (keys, values) in javascript? 6 answers

  • var x = {4214061251:1,2497227651:2,4214140739:2};
    
    // Array of all keys 4214061251, 2497227651 ...
    var keysArr = Object.keys(x);
    console.log(keysArr);
    
    // Iterate on keys
    keysArr.forEach(
      (el) => {
        // To access keys
        console.log("Key: "+el);
        
        // To access values instead
        console.log("Value: "+x[el]);
      }
    )
    链接地址: http://www.djcxy.com/p/52014.html

    上一篇: 如何循环一个简单的对象?

    下一篇: 引用/分析对象