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

xenon thong
xenon thong
3,952 Points

foreach loop vs $.each

Hi guys, i'm fairly new to jQuery and I would like to find out what are the differences between foreach and $.each(). Since both are able to iterate through the array.

1 Answer

Not too sure, but I wouldn't think a whole lot of difference, maybe the way they are implimented... given that jQuery trys to make JavaScript easier and better performance wise, I would think that $.each is may be a little faster and give better results, not really sure lol, but I doubt there is a big difference. At least not anything you will be able to notice.