Questions tagged [each]

An iterator function or language struct which can be used to iterate over arrays or lists.

A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.

jQuery.each( array, callback )
// or
jQuery.each( object, callback )
3858 questions
79
votes
6 answers

Jquery each - Stop loop and return object

Can anybody tell me why the loop did not stop after the 5 entry? http://jsbin.com/ucuqot/edit#preview $(document).ready(function() { someArray = new Array(); someArray[0] = 't5'; someArray[1] = 'z12'; someArray[2] = 'b88'; someArray[3] =…
user970727
  • 1,947
  • 4
  • 22
  • 28
68
votes
7 answers

what's different between each and collect method in Ruby

From this code I don't know the difference between the two methods, collect and each. a = ["L","Z","J"].collect{|x| puts x.succ} #=> M AA K print a.class #=> Array b = ["L","Z","J"].each{|x| puts x.succ} #=> M AA K print b.class #=> Array
mko
  • 21,334
  • 49
  • 130
  • 191
68
votes
3 answers

Last element in .each() set

I have an issue, where by I am doing a simple form validation, that needs some custom stuff that the validation plugin could not do for me. Basically, I have a name, email and message field, all are required, but only email is really validated, the…
Ryan
  • 1,184
  • 1
  • 11
  • 19
67
votes
5 answers

jquery $.each() for objects