foreach()

The foreach linq operator executes some "action" function on each of the elements of the collection. Note that the foreach operator does not return anything.
var arr = ["John", "Mary", "David", "Kenneth"];

var col = $linq(arr);

// alert each of the names
col.foreach(function (x) { alert(x); });

// alert each of the names prefixed with the index (e.g., "(1) John", etc.)
col.foreach(function (x, i) { alert('(' + (i + 1) + ') ' + x); });

Last edited Sep 20, 2012 at 9:32 PM by battousai999, version 1