This question is almost not worth asking, but here I am.
Referencing the question above, here is the code and output
var port = 3000
console.log("Listening on port ", port)
Outputs "Listening on port 3000"
Notice the extra space thrown in there. Why does this occur?
By popular demand, copied from comments:
Because that's what console.log does. Might as well ask why it prints on the console instead of painting your bathroom blue. (Because the latter is not what it does). :) If you don't want the space, use + operator to stitch strings together.
The reason is, likely, the fact that console.log, at least in graphical clients, has the ability to present objects and arrays inline. This makes the displayed result not really a string, but more of a table, with the space separating each cell from another. Each argument is, thus, presented separately.
Also, considering that console.log is used for debugging, console.log(i, j, a[i][j], a[i][j] / 2) showing 3724.712.35 is not really all that useful, when compared to 3 7 24.7 12.35. And writing console.annoying_log(i + ' ' + j + ' ' + a[i][j] + ' ' + a[i][j] / 2) is annoying. I had enough of that from Java, when I was younger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With