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

237
Views
How can I filter an email domain that is a property of an object that is in an array of objects?

I have this array

let registers = [Register, Register, Register];

and

Register {name: 'Ray', email: 'ray@gmail.com', password: '1234'}
Register {name: 'Carl', email: 'carl@gmail.com', password: '4321'}
Register {name: 'Lina', email: 'lina@outlook.com', password: '5678'}

How can I get a new array with the objects that have @gmail.com as email ?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Use Array.filter with String.includes.

Array.filter filters the original array with some condition, where String.includes provides the condition, the email includes a string @gmail.com

const data = [{ name: 'Ray', email: 'ray@gmail.com', password: '1234' },
              { name: 'Carl', email: 'carl@gmail.com', password: '4321' },
              { name: 'Lina', email: 'lina@outlook.com', password: '5678' }];

const output = data.filter(node => node.email.includes('@gmail.com'));;

console.log(output);

about 4 years ago · Juan Pablo Isaza Report

0

You can use filter and regex here /@gmail\.com$/ to get only the elements that ends with gmail.com

enter image description here

const data = [
  { name: "Ray", email: "ray@gmail.com", password: "1234" },
  { name: "Carl", email: "carl@gmail.com", password: "4321" },
  { name: "Lina", email: "lina@outlook.com", password: "5678" },
];

const output = data.filter((o) => o.email.match(/@gmail\.com$/));

console.log(output);

about 4 years ago · Juan Pablo Isaza 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!