Why comma ‘ , ‘ and plus ‘ + ‘ log the console output in different pattern?

+(string concatenation operator) with object will call the toString method on the object and a string will be returned.
So, '' + object is equivalent to object.toString(). And toString on object returns "[object Object]".

With , the object is passed as separate argument to the log method.

Leave a Comment