Skip to content

Instantly share code, notes, and snippets.

@zachwaugh
Created February 23, 2011 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachwaugh/840699 to your computer and use it in GitHub Desktop.
Save zachwaugh/840699 to your computer and use it in GitHub Desktop.
Testing node.js console.log output string quoting
console.log('100', 'something');
console.log(100, 'something');
console.log(100, 'something', 'something else');
console.log(100 + ' something');
console.log('something', 100, 'something');
@zachwaugh
Copy link
Author

Running the above script displays the following output. Seems node.js will surround strings with quotes if the first argument to console.log is a number.

$ node test.js

100 something
100 'something'
100 'something' 'something else'
100 something
something 100 something

@geon
Copy link

geon commented Jul 9, 2015

Thanks!

It seems to have the same behavior with a date object as the first argument, and it was driving me nuts. Tacking on a .toString() fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment