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

199
Views
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
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!