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

155
Views
What is the difference between creating object with NEW keyword using constructor and plain object regarding arrow functions methods?

I have a Function constructor A

function A(){
   this.number = 10;
   this.show = () => console.log(this.number)
}

So, I'm creating an object with this constructor

let a = new A();
//a={
//   number: 10, 
//   show: () => console.log(this.number)
//}

And plain object b

let b = {
   number: 20,
   show: () => console.log(this.number)
}

As result, I can say objects a and b syntactically equal a == b, but why

a.show() // gives 10
b.show() // undefined

I understand that for b, 'this' is a global object, that is why it is undefined in this case, but why there is different behavior for a?

about 4 years ago · Juan Pablo Isaza
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!