JS log object why is showing [object Object]

You are concatenating an object to string

You can console a string and an object by separating it by comma(,)

you can console.log("uniqueProducts:", uniqueProducts );


You are trying to concatenate an object with a string. You can fix it one of two ways:

  1. Remove + from the log call:
console.log("uniqueProducts:", uniqueProducts);
  1. You can use JSON.stringify to print the object as JSON:
console.log("uniqueProducts:", JSON.stringify(uniqueProducts));

+ concatenates strings but object is not a string.

Use console.dir(obj) to display the content of the object.