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

126
Views
Cómo cambiar un settimeout en una función en lugar de una cadena

Aquí están las líneas 38-41 de mi código para un juego de serpientes en JS> Estoy usando JsFiddle

 createSnake(); locateApple(); setTimeout("gameCycle()", DELAY)

El setTimeout tiene el error: la evaluación implícita considera pasar una función en lugar de una cadena.

¿Cómo debo hacer para arreglar esto?

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

0

Consulte https://developer.mozilla.org/en-US/docs/Web/API/setTimeout

setTimeout() acepta function o el code como primer parámetro. No se recomienda usar code . Use function como a continuación,

 function gameCycle() {} setTimeout(gameCycle, 3000); // if your delay is 3s // OR setTimeout(function() {}, 3000);
about 4 years ago · Juan Pablo Isaza Report

0

Deberías usar así: setTimeout(gameCycle, DELAY)

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!