From the course: JavaScript Essential Training

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Arrow functions and "this"

Arrow functions and "this"

- [Instructor] We need to take a quick sidebar here and talk about the arrow function scope and the 'this' keyword. Earlier, we saw that 'this' keyword used when we created an object constructor and you may remember, this keyword can be used inside any object to refer back to the object itself. So for example, here, we have a method inside our object called 'new volume.' New volume contains a function. And inside that function, we console log out the text, this volume in the method. And then we use 'this' keyword to refer to the volume property of the current object. You can see over here that when we use the functions we call it down here, console log(greenpack, newvolume), when we use the function we get the volume in the method, which is eight. So that's what's declared up here. And then afterwards, I use this volume to re-assign a new value to this attribute. And that's the value that's passed in through the new…

Contents