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

167
Views
Variable definida dentro condicional no disponible fuera

Sé que esto es súper básico, pero no puedo entender por qué no funciona. Esperaba ver el elemento .basic_form registrado en el último archivo console.log. En cambio, obtengo lo siguiente:

 if ( typeof basic_form === 'undefined' || basic_form === nulll ){ console.log( 'not defined yet' ); let basic_form = document.querySelector( '.basic_form' ); console.log( basic_form) ; } console.log( basic_form ); Output: 1> not defined yet 2> the element .basic_form 3> Uncaught ReferenceError: basic_form is not defined (???)

¡Cualquier idea sería muy apreciada!

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Las variables declaradas dentro del bloque no son accesibles desde el exterior. Puede encontrar más información sobre este alcance y cierre de variables .

about 4 years ago · Santiago Trujillo Report

0

basic_form está definido dentro de la declaración if, necesita definirlo afuera. Creo que debería ser así.

 let basic_form = document.querySelector( '.basic_form' ); if ( typeof basic_form === 'undefined' || basic_form === nulll ){ console.log( 'not defined yet' ); console.log( basic_form) ; } console.log( basic_form );

about 4 years ago · Santiago Trujillo 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!