Skip to content
This repository was archived by the owner on Nov 27, 2018. It is now read-only.

Iterating an Array

avoidwork edited this page Dec 31, 2012 · 4 revisions

Iterating an Array can be done with array.each(), or by using the hook on Array.prototype. When iterating, this will be the Array. Iteration can be halted by returning false.

var myArray = ["a", "b", "c", "d", "e"];

myArray.each(function (i, idx) {
	if (idx === 3) return false;
	$.log(i);
});

Clone this wiki locally