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

98
Views
How to add a property from an array of JSON objects to a Set in Javascript

I am looking for the most efficient way to loop over multiple array of objects and add values to a set.

// This is how filesData object looks

const filesData : 
{
hashedEmail: "liugdfkjn83i",
name: "JohnSimith"
}
const setOfHashedEmails = new Set<string>();

    for (const filesData of objectDataInS3Folder) {

// filesData is an array of objects

      // Loop over the array of objects and add only the hashedItem to a set
      filesData.forEach(element=> setOfHashedEmails.add(element.hashedEmail));
    }

Is there a better way to loop over the array of objects multiple times and add the hashedEmail to the set (by using spread operator)

Other possible way can be:

    const arrayOfAllUsers = [];
    for (const filesData of objectDataInS3Folder) {
      arrayOfAllUsers.concat(filesData);
    }

    // Create a set of hashed emails
    const setOfHashedEmails = new Set<string>(arrayOfAllUsers.map(item => item.HashedEmail));
about 4 years ago · Juan Pablo Isaza
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!