Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
Set size is zero but entries shows data and size

I am trying to add some values to a set and its not working as intended. when i console.log, it shows set size is zero however when i expand it, it shows values aswell as size. I am assuming this is happening because of asynchronicity but i am not sure how to fix it. I have attached the code below. I have reviewed some of the other threads related to async code but i am still having trouble understanding it. I suppose i have to use promise and await? but i am not sure how and where. Any help would be appreciated. Thank you.

addWeeks() {
  let result: any;
  let weeksSet = new Set();
  forkJoin({
    weeksList: this.weeksService.getWeeksList(),
  }).subscribe((vals) => {
    const { weeksList } = vals;

    result = weeksList.body;

    if (result != null) {
      this.gridData = result["weeksList"];

      this.gridData.forEach((item) => {
        weeksSet.add(item);
      });
    }
  });
}

Screenshot of what i see when i console.log weeksSet.

screenshot

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda