title: Javascript: split string into strings of specific length
body: <p>I have a string to parse into Date</p>
  
  <pre><code>const a = '18122122'
  </code></pre>
  
  <p>and this way(constantly using substr) to parse it is ugly and error-prone</p>
  
  <pre><code>const date = new Date('20' + a.substr(0, 2), a.substr(2, 2) - 1, a.substr(4, 2), a.substr(6,2 ))
  </code></pre>
  
  <p>Do I miss a method like</p>
  
  <pre><code>const dateArray = a.&lt;method&gt;(2) // return ['18', '12', '21', '22']
  dateArray[0] = '20' + dateArray[0]
  dateArray[1] -= 1;
  const date = new Date(...dateArray)
  </code></pre>