How to change string representation of objects in Nodejs debug console view

前端 未结 4 856
轮回少年
轮回少年 2020-12-15 06:24

How do I change the string representation of an object instance in nodejs debug console. Is there a method (like toString() in .NET) I can override?

4条回答
  •  一生所求
    2020-12-15 07:01

    There is a toString() method that you call on another string.

    terms[200]._text.toString()

    You may also be looking for JSON.stringify() which I find extremely useful in debugging. Since JavaScript objects are literally JSON, this will make printing them out to the console simpler.

    console.log(JSON.stringify(terms[200]))

提交回复
热议问题