title: How to convert file to base64 in JavaScript?
body: <p><strong>UPD</strong> TypeScript version is also available in answers</p>
  <p>Now I'm getting File object by this line:</p>
  <pre><code>file = document.querySelector('#files &gt; input[type=&quot;file&quot;]').files[0]
  </code></pre>
  <p>I need to send this file via json in base 64. What should I do to convert it to base64 string?</p>