node.js中的console.log和sys.puts之间的区别? [英] Difference between console.log and sys.puts in node.js?

查看:92
本文介绍了node.js中的console.log和sys.puts之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在node.js中,您可以使用 console.log sys.puts 打印到屏幕。

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 these?

推荐答案

sys.puts 只是在日志中打印给定字符串。

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

但如果要打印更复杂的对象(Array,JSON,JSObject),你必须使用 console.log ,因为你想看里面的对象。

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 例如只给你[object object]。

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

这篇关于node.js中的console.log和sys.puts之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆