title: How do I join an array with the result not being a string in Javascript?
body: <p>I have an array <code>[1,2,3,4,5,6]</code> and a separator <code>'~'</code> and I want to joint them into a new array with <code>'~'</code> being the separator. </p>
  
  <p>I'd like the output to be <code>[1,'~', 2,'~', 3,'~', 4,'~', 5,'~', 6]</code>.</p>
  
  <p>Using <a href="https://lodash.com/" rel="nofollow noreferrer">Lodash</a> I got something like:</p>
  
  <pre><code>var my_array = [1,2,3,4,5,6]
  var separator = '~'
  _.flatten(_.zip(my_array, new Array(my_array.length).fill(separator)))
  </code></pre>
  
  <p>But this feels ugly and I'm sure there is a better way.</p>
  
  <p>EDIT: Even though the array above has <code>int</code>s I'd like this to work for any type of object.</p>