Tsallaka zuwa abun ciki
Justice Tech School

Arrow Functions and this

Arrow functions do not have their own this, they use the one around them. Use regular functions or methods when you need this to be the object.

Example
const obj = {
  n: "box",
  regular() { return this.n; },
  arrow: () => typeof this,
};
console.log(obj.regular(), obj.arrow());

Exercise

Short function.

const f = (x)  x * 2;

Quiz Test

Do arrow functions have their own this?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.