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 Asynchronous Programming with JavaScript What is Asynchronous Programming? Examples of Synchronous and Asynchronous Code

Logging objects to the console

Maybe I missed something in an old vid but this syntax per 3:10 logs the objects to the console. I have no idea what this is:

data.map(p => console.log(p));

Is it some kind of loop? Was this .map function mentioned somewhere earlier?

1 Answer

Steven Parker
Steven Parker
231,268 Points

This is an intermediate-level course, and the "map" function was covered in the beginner-level course JavaScript Array Iteration Methods (and possibly some others also).

It generates a new array by applying the function argument to each element of the given array. How it is being used here seems a bit bizarre — I would have chosen "forEach" instead.

Anytime I run into something I don't recognize (or remember in detail), I just look it up on MDN. For example, here's the MDN page for map().

Thanks Steven - I'll have to check out that array iteration course because its currently not included in the javascript full stack lineup.

And thanks for that MDN link - my searches kept finding the map object but the one you showed is under Arrays which makes total sense now.

Steven Parker
Steven Parker
231,268 Points

You might want to suggest adding that course to the full stack track to the Support folks!