Сохранить в текстовом или HTML -файле очень хорошо

حفظ البيانات في ملف نصي او صفحة ويب مميز جدا//
const downloadToFile = (content, filename, contentType) => {
  const a = document.createElement('a');
  const file = new Blob([content], {type: contentType});
  
  a.href= URL.createObjectURL(file);
  a.download = filename;
  a.click();

    URL.revokeObjectURL(a.href);
};

document.querySelector('#btnSave').addEventListener('click', () => {
  const textArea = document.querySelector('textarea');
  
  downloadToFile(textArea.value, 'my-new-file.txt', 'text/plain');
});

// 222 ---------------
function gateFile() {
const fileE = document.getElementById("fileE").value;

// (A) CREATE BLOB OBJECT
var myBlob = new Blob([fileE], {type: "html/text/plain"});

// (B) CREATE DOWNLOAD LINK
var url = window.URL.createObjectURL(myBlob);
var anchor = document.createElement("a");
anchor.href = url;
anchor.download = "demo.html";
    
// (C) "FORCE DOWNLOAD"
// NOTE: MAY NOT ALWAYS WORK DUE TO BROWSER SECURITY
// BETTER TO LET USERS CLICK ON THEIR OWN
anchor.click();
window.URL.revokeObjectURL(url);
document.removeChild(anchor);

}
//--------------33
const texE=document.getElementById("codeThreeE");

  let blob = new Blob([texE.value], {type: 'text/plain'});
      link.href = URL.createObjectURL(blob); 
      link.download="save way3.text"; 

//--------------44
// btn type link
      function fourway() {

    const codeFourE = document.getElementById("codeFourE");
             
      let link = document.createElement('a');
      link.download = 'save way4.txt';
      let blob = new Blob([codeFourE.value], {type: 'text/plain'});
      link.href = URL.createObjectURL(blob);
      link.click();
      URL.revokeObjectURL(link.href);
         }
//--------------55
     function fiveway() {
      
      const codeFiveE = document.getElementById("codeFiveE");

      let link = document.createElement('a');
      link.download = 'save way5.txt';
      let blob = new Blob([codeFiveE.value], {type: 'text/plain'});
      let reader = new FileReader();
      reader.readAsDataURL(blob); // converts ta blob to base64 and calls onload
      reader.onload = function() {
        link.href = reader.result; // data url
        link.click();
      }; 
           };
//sorce 2 
//1) https://robkendal.co.uk/blog/2020-04-17-saving-text-to-client-side-file-using-vanilla-js
//2) https://code-boxx.com/create-save-files-javascript/
Xanthous Xenomorph