Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

81
Vistas
Appending strings to JSON Files

consider the following code snippet:

let proposals = JSON.parse(fs.readFileSync(proposalsFile, "utf8"))
proposals[network.config.chainId!.toString()].push(proposalId.toString())
fs.writeFileSync(proposalsFile, JSON.stringify(proposals))

The initial proposalFile contains the following: { '31337': [] }

I don't understand what is happening in the second line above. How can the index of the array proposals[] be of type String, if indeed it is an array?

What is the meaning of the ! in ChainId!?

Subsequent executions of this script will result in strings getting appended in the proposalFile:

{"31337":["21810620491323861737494108894072031792136914678422989467418569109597477706871","21810620491323861737494108894072031792136914678422989467418569109597477706871"]}

I understand why this is done, I don't understand how the code snippet results in the above JSON file? The original context of this snippet can be found here: https://github.com/PatrickAlphaC/dao-template/blob/main/scripts/propose.ts

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda