In Chrome, the following
console.log(true, '\t');
will print
true " "
Why are there quotes hanging around?
(Notice that console.log(true + '', '\t') will only print true, in the same way that console.log('a', '\t'); will only print a.)
Basically there are two overloads to console.log:
console.log(formatString, args)andconsole.log(arg1, arg2, ...).More specifically, per the source code, if the first parameter is a string then it treats it as a format string for the other parameters. Otherwise, each parameter is output directly.
Thus
console.log(true + '', '\t')outputs ‘true’ because the first parameter is a string and there is no placeholder for the\t, andconsole.log(true, '\t')will output both parameters becausetrueis not a string.