In JS, if I log a string to the console it is not showing properly ?
console.log(uniqueProducts); //
console.log(\"uniqueProducts:\"+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 );
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));
+
concatenates strings
but object
is not a string.
Use console.dir(obj)
to display the content of the object
.