Difference between console.log and sys.puts in node.js?

后端 未结 7 1745
無奈伤痛
無奈伤痛 2021-01-31 01:38

In node.js you can use console.log or sys.puts to print out to the screen.

What is the preferred method and what is the difference between thes

相关标签:
7条回答
  • 2021-01-31 02:31

    sys.puts simply prints the given string in the logs.

    But if you want to print a more complex object (Array, JSON, JSObject) you have to use console.log because you want to "look inside" of the object.

    sys.puts would give you only "[object object]" for example.

    0 讨论(0)
提交回复
热议问题