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

127
Views
Compruebe las propiedades del objeto js anidado en js

Me gustaría verificar la existencia de una propiedad de objeto js anidada, ¿alguna forma de simplificar este código en una línea?

 if(json_root.hasOwnProperty(p1)){ if(json_root.p1.hasOwnProperty(p2)){ if(json_root.p1.p2.hasOwnProperty(p3)){ /**Do your things with json_root.p1.p2.p3*/ } } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simplemente puede definir una declaración if como esta

 if(json_root.p1 && json_root.p1.p2 && json_root.p1.p2.p3){ // Here add your code }

El código de bloque de la declaración if se ejecutará solo cuando las tres condiciones sean válidas.

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!