1. <script>
    2. /*
    3. object.keys()可以获取对象所有的属性
    4. object.values()可以获取对象所有属性的值
    5. */
    6. var obj = {
    7. name:"李四",
    8. age:39
    9. }
    10. var keys = Object.keys(obj)
    11. var values = Object.values(obj)
    12. console.log(obj)
    13. console.log(values)
    14. </script>
    1. <script>
    2. var arr ={
    3. A:[{city:"武汉"},{city:"广州"}],
    4. B:[{city:"深圳"},{city:"广州"}],
    5. C:[{city:"上海"},{city:"武汉"}],
    6. }
    7. var values = Object.values(arr);
    8. values.forEach(item=>{
    9. console.log(item)
    10. item.forEach(city=>{
    11. console.log(city)
    12. })
    13. })
    14. </script>