VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-this-binding/

⇱ Node.js This Binding - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js This Binding

Last Updated : 25 Apr, 2026

Arrow functions do not bind their own this and instead inherit it from the surrounding scope. This makes them useful for callbacks but unsuitable for object methods.

  • Arrow functions use lexical this from the outer scope.
  • Not suitable for object methods because this won’t refer to the object.
  • ES6 method shorthand should be used for defining methods.
  • Ideal for callbacks like forEach where outer this access is needed.

Filename: index.js

Run index.js file using the following command:

node index.js
👁 Screenshot-2026-03-06-182721
  • Arrow functions use lexical this, so they access the object’s this correctly.
  • In eventOne, this.name works because the arrow function inherits this.
  • Normal functions have their own this, so context is lost inside forEach.
  • In eventTwo, this.nanome becomes undefined inside the callback.

So this is how 'this' binding works on arrow functions and normal functions.

Comment
Article Tags:

Explore