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

前端 未结 17 3328
一向
一向 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:22

    The node REPL has a built-in solution for overriding how objects are displayed, see here.

    The REPL module internally uses util.inspect(), when printing values. However, util.inspect delegates the call to the object's inspect() function, if it has one.

提交回复
热议问题