function downloadCsv() {
var blob = new Blob([csvString]);
if (window.navigator.msSaveOrOpenBlob){
window.navigator.msSaveBlob(blob, "filename.csv");
}
else {
var a = window.document.createElement("a");
a.href = window.URL.createObjectURL(blob, {
type: "text/plain"
});
a.download = "filename.csv";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
}
var string = "a1,a2,a3";
downloadCSV(string);
Source reference ; https://github.com/mholt/PapaParse/issues/175