jQuery .each() skip to next one

By Sam Deering

Workaround jQuery code snippet to skip next interation in a loop. Just documenting this code snippet, no demo sorry.

//output keys=values. eg [1]=[2], [3]=[4] etc, skips undefined keys
var i = 0;
$.each(array, function(key, val)
	if (webTrendsParams[i]) {
		console.log(array[i] + ' = ' + array[i+1]);
	i = i + 2;

No Reader comments


Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Get the latest in JavaScript, once a week, for free.