How can I get the full object in Node.js's console.log(), rather than '[Object]'?

前端 未结 17 2900
一向
一向 2020-11-22 02:59

When debugging using console.log(), how can I get the full object?

const myObject = {
   \"a\":\"a\",
   \"b\":{
      \"c\":\"c\",
      \"d\":         


        
17条回答
  •  一向
    一向 (楼主)
    2020-11-22 03:26

    JSON.stringify()

    let myVar = {a: {b: {c: 1}}};
    console.log(JSON.stringify( myVar, null, 4 ))
    

    Great for deep inspection of data objects. This approach works on nested arrays and nested objects with arrays.

提交回复
热议问题