Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

235
Vistas
Some error on constructor and recursion i don't seem to understand

I'm working on constructor, at first I was using ES5 and my error was "Message is not a function" then I saw something about arrow function not been used with constructor so I removed it and got another error saying "Maximum call stack size exceeded" something about recursion. I don't know what exactly I'm doing wrong. have seen a lot of answers on constructor but none of them seems helpful.

function Message(name, motive, hubby){
 this.name = name
 this.motive  = motive
 this.hubby = hubby
 this.output=function(){
return `Hi, i'm ${this.name} i love ${this.hubby} and i would love to be your ${this.motive}.`
}
 var Mymessage = new Message('josephine','friend', 'coding');
 console.log(Mymessage.output()); 
}
 Message();
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

This is how you should create an instance and call a function of that instance

function Message(name, motive, hubby){
     this.name = name
     this.motive  = motive
     this.hubby = hubby
     this.output=function(){
    return `Hi, i'm ${this.name} i love ${this.hubby} and i would love to be your ${this.motive}.`
    }
}
var Mymessage = new Message('josephine','friend', 'coding');
console.log(Mymessage.output()); 
about 4 years ago · Juan Pablo Isaza Denunciar

0

function Message(name, motive, hubby){
 this.name = name
 this.motive  = motive
 this.hubby = hubby
 this.output=function(){
  return `Hi, i'm ${this.name} i love ${this.hubby} and i would love to be your ${this.motive}.`
  }
}
 var Mymessage = new Message('josephine','friend', 'coding');
 console.log(Mymessage.output()); 
 Message();

You must write var Mymessage outside the Message function , as you have called it inside the same function, that line of code is calling itself again and again which is causing an erro .

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda