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

152
Views
Check if the value of a variable exists in an object

I have a Typescript project where I need to know if the value of a variable is in any property of the Object.

This is the object:

let listDump = [
   {
     "properties":{
        "title":"CARS"
     }
  },
  {
     "properties":{
        "title":"HOME"
     }
  },
  {
     "properties":{
        "title":"COUNTRY"
     }
  }
];

This is the declared variable:

let newData = 'ANIMALS'

This is what I do to check if it exists:

for (let sheet of listDump) {
  if (sheet.properties.title == newData) {
    console.log(`do not create property`)
  } else {
    console.log('create property') 
  }
}

Problem: Doing three checks operates three times on the else

What I need to know is how to check that it exists without needing to iterate over the object and operate only once in case it doesn't exist

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

0

You can use <Array>.some

listDump.some(sheet => sheet.properties.title == newData) // returns true | false
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!