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

247
Views
How can I get a key value from an array that has object inside

Imagine I have something like this:

const myArray = [
    {
        Email:example@example.com,
        Password:1234,
        Username:myname
    }
]

How can I access email value inside of object in easier way? I know can do some looping or mapping then using for of or something like that but is there any better way?

I want to do a check like that:

const otherArray = [
    {
        Email:example@notexample.com,
        Username:myname,
        Password:1234
    }
]

If the Email value inside of myArray is equals to the value of otherArray then if it does:

  • return true
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You can use Array.some() method.

Working Demo :

const myArray = [
    {
        Email: 'example@example.com',
        Username: 'myname',
        Password: 1234
    }, {
        Email: 'example1@example.com',
        Username: 'myname1',
        Password: 5678
    }, {
        Email: 'example2@example.com',
        Username: 'myname2',
        Password: 8756
    }
];

const otherArray = [
    {
        Email: 'example@notexample.com',
        Password: 1234,
        Username: 'myname'
    }
];

const res = myArray.some(obj => obj.Email === otherArray[0].Email);

console.log(res); // false as example@example.com is not equal to example@notexample.com.

about 4 years ago · Juan Pablo Isaza Report

0

Some examples (with the syntax error fixed on the values)

let myname = "I create sntax errors";
const myArray = [{
  Email: "example@example.com",
  Password: "1234",
  Username: myname
}];

const otherArray = [{
  Email: "example@notexample.com",
  Username: myname,
  Password: "1234"
}];

const otherArrayAlso = [{
  Email: "example@example.com",
  Username: myname,
  Password: "1234"
}];
let isMatch = myArray[0].Email == otherArray[0].Email;
console.log(myArray[0].Email, otherArray[0].Email);
console.log("IsMatch:", isMatch);
console.log(myArray[0].Email == otherArrayAlso[0].Email);

about 4 years ago · Juan Pablo Isaza Report

0

You can simply check like this

const myArray = [
  {
    Email: 'test@test.com',
    Age: 30,
  },
  {
    Email: 'One@test.com',
    Age: 24,
  },
  {
    Email: 'Two@test.com',
    Age: 20,
  },
]

const otherArray = [
  {
    Email: 'Three@test.com',
    Age: 30,
  },
  {
    Email: 'test@test.com',
    Age: 24,
  },
  {
    Email: 'Four@test.com',
    Age: 20,
  },
]

let found = false;

const otherArrayEmails = otherArray.map(item => item.Email);
for (let i = 0; i < myArray.length; i++) {
   if (otherArrayEmails.includes(myArray[i].Email)) {
      found = true;
      break;
   }
} 
console.log(found)

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!