JS log object why is showing [object Object]
You are trying to concatenate an object with a string. You can fix it one of two ways:
- Remove
+
from the log call:
console.log("uniqueProducts:", uniqueProducts);
- You can use
JSON.stringify
to print the object as JSON:
console.log("uniqueProducts:", JSON.stringify(uniqueProducts));
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 );