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

238
Views
"this" keyword in an arrow function

I understood that the "this" keyword means the current execution context, or where the code was invoked. It may be the global object or an object that called it.

const nameObj = {
  name: "Jack",
logName: function(){
console.log(this.name)}
}
nameObj.logName() // Jack

It works fine for the regular functions, but for the arrow functions it returns the global object instead:

const nameObj = {
  name: "Jack",
logName: ()=> {
// console.log(this.name) would be undefined
console.log(this)
}
}
nameObj.logName() // The window object on the browser's console

Everything is clear till this point, however, I cannot understand when it comes to nesting an arrow function inside a regular function, the "this" keyword in the arrow function refers to the object that called it instead of the usual global or window object.

const nameObj = {
  name: "Jack",
  logName: function () {
    return () => console.log(this.name);
  },
};
const arrowLogName = nameObj.logName();
arrowLogName(); // Jack

Is the arrow function implicitly "capturing" the "this" value or something else I am missing?

about 4 years ago · Santiago Trujillo
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!