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

136
Vistas
Does JavaScript provide a way to build a new collection with just one property from another collection?

In C#, I can do the following:

class Item
{
    public string Name { get; set; }
    public string Email { get; set; }
    public string Phone { get; set; }
}

Item[] Items = new[]
{
    new() { Name = "Bob", Email = "Bob@domain.com", Phone = "555-5555" },
    new() { Name = "Carl", Email = "Carl@domain.com", Phone = "555-5555" },
    new() { Name = "Ted", Email = "Ted@domain.com", Phone = "555-5555" },
};

IEnumerable<string> names = Items.Select(i => i.Name);

The last line builds a collection of just the names from Items ("Bob", "Carl" and "Ted").

Is there a way to do the same thing in JavaScript without writing a loop and building the array yourself?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There is a similar concept in JavaScript and it is called the map :)

let details = [
  { id: 1, name: 'John' },
  { id: 2, name: 'Steve' },
  { id: 3, name: 'Mike' },
  { id: 4, name: 'Ericson' }
];

console.log(details.map(detail => { return detail.name }))

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