Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
Cómo leer/escribir/editar archivos con Javascript

Quiero crear un juego que guarde tu progreso usando archivos. ¿Es posible hacer algo similar a este pseudocódigo?

 /*game_data = The game's content*/ function saveGame () { create_file(game_data, "your-game-progress.txt") } function loadGame () { game_data = load_file("your-game-progress.txt") }

¿Hay alguna forma de lograr esto, con o sin bibliotecas externas?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

¿Está utilizando un marco como React o NextJS? Si es así, hay varias opciones para el almacenamiento de archivos planos.

Si usa Vanilla JS, su única opción real para el almacenamiento del lado del cliente es el método localStorage() .

 /*game_data = The game's content*/ var game_data = { "player_name": "Joe", "experience": 4347873, "level": 10, "HP": 255 }; function saveGame () { localStorage.setItem('game_data', game_data); //create_file(game_data, "your-game-progress.txt") } function loadGame () { game_data = localStorage.getItem('game_data'); //game_data = load_file("your-game-progress.txt") } function deleteGame() { localStorage.removeItem('game_data'); /* OR */ localStorage.clear(); // clears all local storage items }

El problema, sin embargo, es que los datos del juego se perderán cuando la cookie caduque o el usuario borre sus cookies o use un navegador diferente. Es posible que desee considerar una solución del lado del servidor.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!