1var string = "Hello folks how are you doing today?";
2var encodedString = btoa(string); // Base64 encode the String
3var decodedString = atob(encodedString); // Base64 decode the String
4
1// Define the string
2var string = 'Hello World!';
3
4// Encode the String
5var encodedString = btoa(string);
6console.log(encodedString); // Outputs: "SGVsbG8gV29ybGQh"
7
8// Decode the String
9var decodedString = atob(encodedString);
10console.log(decodedString); // Outputs: "Hello World!"
11
1const encoded = window.btoa('Alireza Dezfoolian'); // encode a string
2const decoded = window.atob(encoded); // decode the string
3
1str = "The quick brown fox jumps over the lazy dog";
2b64 = btoa(unescape(encodeURIComponent(str)));
3str = decodeURIComponent(escape(window.atob(b64)));