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

128
Views
¿Cómo verificaría si la cadena es igual a un valor en un objeto?

Tengo un objeto llamado códigos:

 var codes = { code1: 'test1' code2: 'test2' }

Y quiero verificar si tiene una propiedad y registrar el resultado en la consola.

 if(input == what goes here) { console.log("Has property") }

Lo siento si es una respuesta muy obvia, soy bastante nuevo en Javascript

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

0

Puedes usar hasOwnProperty() :

 var codes = { code1: 'test1', code2: 'test2' } console.log(codes.hasOwnProperty('code1')); console.log(codes.hasOwnProperty('code2')); console.log(codes.hasOwnProperty('code3'));

 if(codes.hasOwnProperty(input)){ }
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!