Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Introducing ES2015 The Cooler Parts of ES2015 Arrow Functions

israel meza
PLUS
israel meza
Courses Plus Student 10,890 Points

arrow-this.js

Im having trouble following the code of arrow-this.js before he changed to arrow functions. On line 26 when .then() is called it takes in an anonymous function which take in 'classroom'. Im assuming that Hello to ${studentCnt} of my favorite students!gets passed in as geeting parameter in the inner function, but im not sure where classroom comes from.

1 Answer

Steven Parker
Steven Parker
231,269 Points

The parameter given to the outer anonymous function is "classroom".

Though the parameter name is "classroom", this function is immediately invoked with an argument of this, which would represent the current Classroom object. Then the inner function is returned as the result.

This is the part the instructor admits is "pretty hard to read"!