title: How to add header to csv file in more efficient way
body: <p>I have a function which writes values to a csv file from an array in some response, but before that I need to provide headers with the field name in the first line for each tab so I have written the headers in using <code>csv += '/t header 1',csv += '/t header 2'</code> and so on.</p>
  
  <p>Here is my block of code</p>
  
  <pre><code>function exportToCsv(fName, rows) {
      var csv = 'branch';
      csv += '\t customerId';
      csv += '\t customerName';
      csv += '\t LOAN ID/UT unique ID';
      csv += '\n';
      for (var i = 0; i &lt; rows.length; i++) {
          var row = Object.values(rows[i]);
          for (var j = 0; j &lt; row.length; j++) {
              var val = '';
              val = row[j] === null ? '' : row[j].toString();
              if (j &gt; 0)
                  csv += '\t';
              csv += val;
          }
          csv += '\n';
      }
  }
  </code></pre>
  
  <p>Is there any efficient way to write those five lines in above function? The current code is working but I'm looking for a more efficient way to replace these lines. </p>
  
  <p>Also note I have just mentioned a few header names here but I actually have 20 - 30 headers fields. </p>
  
  <p>Please share your thoughts.</p>