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

80
Views
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
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!