JSFiddle - React, Tailwind, and code Playground
JavaScript 1.7
const items = [
{a: 1, b: 2},
{a: null, b: 3}
]
const replacer = (key, value) => value === null ? '' : value // specify how you want to handle null values here
const header = Object.keys(items[0])
let csv = items.map(row => header.map(fieldName => JSON.stringify(row[fieldName], replacer)).join(','))
csv.unshift(header.join(','))
csv = csv.join('\r\n')
console.log(csv)