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

157
Views
why "this" keyword in arrow function represents the object rather than global object(window)

I am learning the behavior of this keyword in ES6 class , before I have learnt that this keyword in object functions, represent the following :

  • In regular function, this represents the the current object.
  • In arrow function, this represent the global object(window).

So, when I worked with ES6 class I see that Class behave as Object when it is complied into JavaScript ,I see this behavior in console by putting this in a class method and this was representing the current class as Object as well as its prototype was Object.

For conceptual understanding, I make one Arrow function foo() and one Regular function bar() in a class AppComponent and print this keyword as follow:

enter image description here

I was expecting that this in foo() would represent global object(window) , because it is inside Arrow function in the Object and ,on the other side,in the bar() this represent the current object due to Regular function inside object which is AppComponent, but the output was:

enter image description here

bar() output is expected.

foo() output is unexpected.

So, my question is that why this represent the current Object Appcomnent rather than global object(window), because it is inside the arrow function in the object .

Please correct me if my concept is not correct in the question ,if it is correct then why I see the unexpected output. I would very thankful to you for your contribution.

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!