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

156
Views
Trying to understand difference beetween functions arrow and functions in javascript

I'm trying to understand the difference beetween functions arrow and functions in javascript, with the help of some website, and from what I seemed to understand, it's the this binding that change in the case So I understood that in function arrow, this is binded to the closest non-arrow function parent this and in regular function, this is binded from the closest this

So with that in mind, I was doing some test in the browser console and came up with this:

test = {
    test_name: "OK",
    test_func: function() {
        console.log(this.test_name);
        (() => {
            console.log(this.test_name);
            function b() {
                console.log(this.test_name);
            }
            b();
        })();
    }
}
test.test_func();

I was excepting to get

OK
OK
OK

but what I get is

OK
OK
undefined

And I can't understand why since I get 'OK' in the arrow function, why don't I get 'OK' in the b() function?

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

0

From w3schools:

The handling of this is also different in arrow functions compared to regular functions.

In short, with arrow functions there are no binding of this.

In regular functions the this keyword represented the object that called the function, which could be the window, the document, a button or whatever.

With arrow functions the this keyword always represents the object that defined the arrow function.

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!