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

232
Views
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 answers
Answer question

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 Report

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 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!