javascript - Unable to figure out whether to use "," or "+" in console.log in node.js -


this config.json file:

{ "username": "myname", "api-key": "test", "name": "testname", "version": 1 } 

this node.js file

var fs=require("fs"); console.log("start"); var contents=fs.readfilesync("config.json"); console.log("contents: " +contents); var config=json.parse(contents); console.log("username: ", config.username); 

now whether use

console.log("username: ", config.username);  

or use

console.log("username:" +config.username); 

i same result in output. gives different results while logging other variables. unable when "," used , when "+" used. pointers?

if use + concatenation operator, , pass single string (or number) log().

if use ,, passing multiple arguments.

if pass multiple arguments, , aren't using formatting string, each logged via inspect.

see documentation console.log , util.inspect more details.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -