Arrow Functions with Context
printName that logs the name property of a given object to the console. The function should use the call() method to execute in the context of the object.Solution Walkthrough for Arrow Functions with Context
Spoiler Alert!
Don't read this unless you've already solved the problem.
call() method to execute the printName function in the context of the object, so that when printName.call(person) is called, the function is executed in the context of the person object and logs "John Doe" to the console.this keyword is inherited from the parent scope and is not redefined. Therefore, in order to use the call() method to execute an arrow function in a specific context, we need to define the arrow function using the function keyword, or use other methods such as bind() or apply().