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

308
Views
TypeError: Person.greet no es una función

 function Person(name, age, greet) { this.name = 'Josh'; this.age = 15; this.greet = function(greeting) { console.log('Hello I am ', this.name) } } Person.greet();

Estoy tratando de hacer que la consola muestre "Hola, soy Josh", aparece el mismo error que dice Person.greet no es una función

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

0

 function Person(name, age, greet) { this.name = name; this.age = age; this.greet = function(greeting) { console.log('Hello I am', this.name) } } const max = new Person(); max.name = 'max'; max.age = 18; max.greet(); // Hello I am max

Me di cuenta de que estaba usando una función de fábrica, estaba destinado a crear un objeto usando la nueva palabra clave

about 4 years ago · Juan Pablo Isaza Report

0

Esto parece ser una función constructora y no un objeto, por lo tanto, debe llamar a new para crear una instancia de la función constructora antes de invocar los métodos.

 // on a side note, if you're not going to use the arguments, better remove them altogether function Person(name, age, greet) { this.name = 'Josh'; this.age = 15; this.greet = function(greeting) { console.log('Hello I am ', this.name) } } const person = new Person(); person.greet();

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!