Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Introducing ES2015 The Cooler Parts of ES2015 Arrow Functions

israel meza
israel meza
Courses Plus Student 10,890 Points


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
216,083 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"!