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

243
Views
Navegación/iteración en el objeto como interfaz para obtener el par clave-valor
export interface Worker { salary?: number; manager?: boolean; name?: string; hired?: Date; } const worker1: Worker = { salary: 5000, manager: true, name: "Bob", birth: new Date() };

Necesito obtener todos los pares de atributos como clave - valor.

 for (const [key, value] of worker1????) { console.log("key: '" + key + "', value: " + value); // to do other needed operations }

El resultado esperado para esta pregunta de registro es:

 key: 'salary', value: 5000 key: 'manager', value: true key: 'name', value: Bob key: 'birth', value: xxxxx

¿Cómo lograr eso?

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

0

Creo que solo quieres el método Object.entries() ?

 for (const [key, value] of Object.entries(worker1)) { console.log("key: '" + key + "', value: " + value); }
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!