Creating a CSV with JavaScript

csvEndLine = '\n ';  
csvHeading  =   ' UserName, FirstName, LastName, Email';  
csvData     =   ' Trozdol, Shayne, Trosdahl, notmine@domain.com' +  
                ' BSDPunk, Dustin, Carver, nothis@domain.com';
csvFile     =   csvHeading + csvData;

window.location = 'data:text/csv;charset=utf8,' + encodeURIComponent(CSVFile);