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

157
Views
accessing whether a value is inside an Object or not

how can i know if a value is in my object in Js, I don't know how to explain it exactly but I hope the code simplifies it for you

let object = {
  1: hey
  2: hi
  3: hello
}
let exist = object.value("hello")
console.log(exist) //should print true
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

let object = {
  1: "hey",
  2: "hi",
  3: "hello"
}
let exist = Object.values(object).includes("hello")
console.log(exist)

about 4 years ago · Juan Pablo Isaza Report

0

There are plenty of ways to check if a value is contained within an object.

A simple one is by accessing the Object.values(myObject).

Should look like this:

console.log(Object.values(myObject).some(elem => (elem === ('hello'))));
// true
about 4 years ago · Juan Pablo Isaza Report

0

You can use Object.values

let object = {
  1: "hey",
  2: "hi",
  3: "hello"
}
   
let exists = Object.values(object).includes("hello");
console.log(exists);
exists = Object.values(object).includes("world");
console.log(exists);

But if you need checks like this quite often, you should probably think about a data structure better supporting that scenario ...

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!