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

Php - Delimiter must not be alphanumeric or backslash -

c# - How to change the "Applies To" field under folder auditing options programatically (.NET) -

c++ - Ambiguity when using boost::assign::list_of to construct a std::vector -