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

170
Views
Estoy confundido, recibo "getMonth no es una función"

aunque asigné una fecha a la variable, recibo el mensaje de error "getMonth no es una función"

Evidentemente el intérprete no acepta el tipo de fecha.

Esta es la sección relevante del código:

 function init(){ var m=document.getElementById("m"); var d = Date(); refresh(d); } function refresh(d) { var month = d.getMonth();

sí, la función termina con un }, hay más líneas, pero se detiene exactamente allí.

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

0

Olvidó usar nueva palabra clave con Fecha:

 function init(){ var m=document.getElementById("m"); var d = new Date(); refresh(d); } function refresh(d) { var month = d.getMonth(); console.log(month) } init()

about 4 years ago · Juan Pablo Isaza Report

0

Parece que desea obtener el constructor, mientras actualmente está definiendo la función como d .

Lea más sobre Date aquí: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

Entonces, el fragmento de código debería ser:

 function init(){ var m=document.getElementById("m"); var d = new Date(); refresh(d); } function refresh(d) { var month = d.getMonth();
about 4 years ago · Juan Pablo Isaza Report

0

La Date es una clase en javascript, por lo que debe usar la new palabra clave para crear una nueva instancia y llamar a métodos como getMonth en ella.

 function init(){ var m=document.getElementById("m"); var d = new Date(); refresh(d); } function refresh(d) { var month = d.getMonth(); console.log(month); } init();

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!