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

117
Views
What function constructor returns in JavaScript

I came accross with a question #83 in https://github.com/lydiahallie/javascript-questions

function Car() {
  this.make = 'Lamborghini';
  return { make: 'Maserati' };
}

const myCar = new Car();
console.log(myCar.make);

To my understanding the code should log 'Lamborghini'and conso;e.log(myCar().make) should log 'Maserati' But I'm totally wrong, myCar is not a function. Why?

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

0

If you intend to use your function as a constructor you don't need to return anything from it. When you invoke your function with new keyword Javascript will create a new object under the hood, bind it to this and return it by default

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!