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 trialScott Whitener
3,997 PointsLogging 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
231,236 PointsThis 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().
Scott Whitener
3,997 PointsScott Whitener
3,997 PointsThanks 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
231,236 PointsSteven Parker
231,236 PointsYou might want to suggest adding that course to the full stack track to the Support folks!