Output of this code

const shape = {
radius: 10,
diameter() {
return this.radius * 2;
perimeter: () => 2 * Math.PI * this.radius,



Arrow functions and this

Add a console.log(this) to each of your methods and see if you notice a difference. This is intentional. Arrow function methods do not bind to the this of their object. That’s why you should not use them if you need to reference a property in the object.

I’m sure if you google for “arrow functions and this” you will get a much better explanation than I have time to give here :slightly_smiling_face:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.