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

186
Views
Javascript addeventlistener trabajando sin parámetros

Estaba buscando documentación de javascript y encontré esto

 const log = document.getElementById('log'); document.addEventListener('keydown', logKey); function logKey(e) { log.textContent += ` ${e.code}`; }

No entiendo cómo funciona la función logkey en addeventlistener. cuando presiono una tecla, la consola imprime su código pero logkey no tiene ningún parámetro en addeventlistener. ¿Cómo imprimió e.code?

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

0

Pasas la función como un parámetro al eventListener. eventListener llama a la función logKey con el evento como parámetro de función.

Vea en el siguiente ejemplo cómo se pasa un parámetro a la función:

 function func1(function_as_parameter){ function_as_parameter('Shivam'); } function helloWordFunction(name){ console.log(`Hello ${name}!`); } func1(helloWordFunction); // Hello Shivam!
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!