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

188
Views
cómo obtener propiedades únicas del objeto <Mapa>

Tengo un mapa y con un objeto que contiene una lista de matrices. Por ejemplo:

 Map(1) {'SAMSUNG' => Array(5)} [[Entries]] 0: {"SAMSUNG" => Array(5)} key: "SAMSUNG" value: Array(5) 0: {externalKey: '0001', brand: 'V', country: 'DE', deviceType: 'TSU4'} 1: {externalKey: '0002', brand: 'V', country: 'FR', deviceType: 'TSU1'} 2: {externalKey: '0005', brand: 'N', country: 'DE', deviceType: 'TSU4'} 3: {externalKey: '0008', brand: 'V', country: 'AB', deviceType: 'TCU4'} 4: {externalKey: '0009', brand: 'G', country: 'DE', deviceType: 'TCU7'} length: 5 [[Prototype]]: Array(0) size: 1 [[Prototype]]: Map

Me gustaría saber cómo puedo obtener el país de marca único y el tipo de dispositivo, por ejemplo: marca ['V', 'N', 'G'].

Primero necesito saber cómo acceder a este valor de mapa Matriz de 5 valores.

Intenté algo como esto:

 Object.keys(myObj)

Pero me da 'indefinido'

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Su mapa tiene una clave "SAMSUNG", y puede obtener su contenido con mymap.get("SAMSUNG") . Eso será una matriz en este caso.

Aquí hay un ejemplo de cómo podría haberse construido ese mapa, cómo puede obtener acceso a la matriz y cómo podría agrupar países por marca (solo como ejemplo):

 // Create the map (you already have it -- so you wouldn't do this) const map = new Map().set("SAMSUNG", [ {externalKey: '0001', brand: 'V', country: 'DE', deviceType: 'TSU4'}, {externalKey: '0002', brand: 'V', country: 'FR', deviceType: 'TSU1'}, {externalKey: '0005', brand: 'N', country: 'DE', deviceType: 'TSU4'}, {externalKey: '0008', brand: 'V', country: 'AB', deviceType: 'TCU4'}, {externalKey: '0009', brand: 'G', country: 'DE', deviceType: 'TCU7'} ]); // Get access to the array const arr = map.get("SAMSUNG"); // Example: group countries by brand const groups = {}; for (const {brand, country} of arr) (groups[brand] ??= []).push(country); console.log(groups);

about 4 years ago · Santiago Gelvez 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!