Convert binary form to Base 64 for Javascript [duplicate]

     
  

This question already has an answer here:

     
  

in PHP I have this code to convert a string to binary and encode to Base 64:



But how I can do that in Javascript ?


Thank you!

  
"
answer1
  
  

See text_to_binary here in SO.


Use btoa() and atob() to convert to and from base64 encoding.