I am wondering what does this three dot operator do in this case:
const csv = [
columns
...data
].map((row) => {
return Object.values(row).join(",");
}).join("\n");
I am trying to convert data to CSV, and if I assign data in the array without three dots operator like this:
const csv = [columns, data].map ...
It returns [object Object]
, while the one with three dot operators returns the correct data.
What does the operator do here?
I want to add a ternary operator but it seems like it's prohibited with a three dots operator.
what I want to achieve:
const csv = [
columns
(condition) ? ...anotherData : ...data
].map ...