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

Robert O'Toole
Robert O'Toole
6,366 Points

confused about catch method

.catch(err=>console.log(err));

how does .catch know that err is a function? how does it know what to log when we simply put log(err)... i wish guil explained some of these parameters a bit better instead of just typing them in

3 Answers

Robert O'Toole
Robert O'Toole
6,366 Points

it is an implicit function. i am just finally grasping all of this because i ventured out of treehouse for a bit. but you guys need to require the ECSM2015 course in the front end track... you guys also should really go into more detail about .map, .filter etc so we can see example of this.

not once in the course was this kind of function writing done and now all of a sudden its been added as a regular way of writing functions. when were arrow functions really covered? when were implicit functions really covered? they weren't.... the jump from beginner to intermediate level stuff was immense and not really practical for anyone who solely focuses on on their studying through these courses. in other words you guys really need to update the front end track... i understand we need to venture out for other resources but i just started taking a course on udemy and the linear fashion of teaching this stuff is way more approachable. half the course uses var and then we all of a sudden start using const, constructors, and things we were never even taught. the OOJS stuff comes after this content which doesn't really make sense. sorry to rant but this needs to be said

Steven Parker
Steven Parker
231,269 Points

Robert O'Toole — Normally the "best answer" mark would go on the answer that helped most towards answering your question (instead of on your own comments). :wink:

Steven Parker
Steven Parker
231,269 Points

The identifier err in that snippet isn't a function, it's a parameter for the function. The function itself is anonymous (has no name).

And catch is designed to take a function as its parameter, so it is expecting it.

For more details on syntax and usage, see the MDN page for Promise.prototype.catch().