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

108
Views
Why arrow function has different parent-scope in this two scenarios?

I know arrow functions binds the parent-scope to 'this' keyword, but is it not the same parent calling the arrow function in this two scenarios?

Both are being called by a console.log inside a "fn" function. Why do I receive different context output?

Expected:

function wuwu() {
    this.a = () => this

    this.fn = function () {
        console.log(this) // wuwu {a: ƒ, fn: ƒ}
        console.log(this.a()) // wuwu {a: ƒ, fn: ƒ}
    }
}
const wewe = new wuwu()
wewe.fn()

Not expected:

let wuwu = {
  a: () => this,
    
  fn: function() {
      let fn2 = () => {
          console.log(this) // {a: ƒ, fn: ƒ}
          console.log(this.a()) // Window {0: Window, 1: Window, window: Window, self: Window, document: document, name: '', location: Location, …}
      }
      fn2()
 }
}
wuwu.fn()
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!