可以序列化成json再打印
var obj = { name: "Tom", age: 23, friends: [ { name: "Jack", age: 20, }, ], }; console.log(obj); // { name: 'Tom', age: 23, friends: [{ name: 'Jack', age: 20 }] } console.log(JSON.stringify(obj, null, 4)); /** { "name": "Tom", "age": 23, "friends": [ { "name": "Jack", "age": 20 } ] } */