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

270
Vistas
how to get length of WeakMap?

I have a WeakMap like this:

let obj = new WeakMap();
let objKey1={"a":1};
let objKey2={"b":2};
let objKey3={"c":3};

obj.set(objKey1,"value1");
obj.set(objKey2,"value2");
obj.set(objKey3,"value3");

Is there a way to get the length / number of keys stored in obj?

I tried Object.keys(obj).length but it returns 0

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

0

From the documentation

But because a WeakMap doesn't allow observing the liveness of its keys, its keys are not enumerable. There is no method to obtain a list of the keys.

It should therefore follow that there is no way to get the number of keys either.

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