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

115
Views
Javascript: comprensión de la función Javascript generada y matrices asociativas de Typescript

Soy novato en Typescript y estoy confundido por el Javascript generado a continuación.

Texto mecanografiado original:

 enum DaysOfTheWeek { SUN, MON, TUE, WED, THU, FRI, SAT }; let day: DaysOfTheWeek; day=DaysOfTheWeek.MON; if (day === DaysOfTheWeek.MON) { console.log("Got to go to work!"); }

Javascript generado:

 var DaysOfTheWeek; (function(DaysOfTheWeek) { DaysOfTheWeek[DaysOfTheWeek["SUN"] = 0] = "SUN"; DaysOfTheWeek[DaysOfTheWeek["MON"] = 1] = "MON"; DaysOfTheWeek[DaysOfTheWeek["TUE"] = 2] = "TUE"; DaysOfTheWeek[DaysOfTheWeek["WED"] = 3] = "WED"; DaysOfTheWeek[DaysOfTheWeek["THU"] = 4] = "THU"; DaysOfTheWeek[DaysOfTheWeek["FRI"] = 5] = "FRI"; DaysOfTheWeek[DaysOfTheWeek["SAT"] = 6] = "SAT"; })(DaysOfTheWeek || (DaysOfTheWeek = {})); ; var day; day = DaysOfTheWeek.MON; if (day === DaysOfTheWeek.MON) { console.log("Got to go to work!"); }

Preguntas:

  1. La var DaysOfTheWeek no parece ser una matriz. Por lo que entiendo, una matriz necesita una instancia de matriz vacía como la siguiente:

    varar = [];

  2. Las matrices solo usan index. Sin embargo, tenemos DaysOfTheWeek[DaysOfTheWeek["SUN"] = 0] = "SUN"; ¿Parece matrices asociativas? ¿Alguien puede explicar lentamente en pasos?

     DaysOfTheWeek[DaysOfTheWeek["SUN"] = 0] = "SUN"; -- breaking it down below 1. DaysOfTheWeek["SUN"] = 0 -- seems like assigning key "SUN" with value 0? 2. DaysOfTheWeek[DaysOfTheWeek["SUN"] = 0] = "SUN" -- this part confuses me!!
  3. En la función (DaysOfTheWeek) en sí, estoy confundido con la construcción stmt B en la parte inferior de esta función. ¿Qué es esto?

Agradezco cualquier ayuda.

about 4 years ago · Juan Pablo Isaza
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!