By Sam Deering

jQuery .each() skip to next one

By Sam Deering
Last chance to win! You'll get a... FREE 6-Month Subscription to SitePoint Premium Plus you'll go in the draw to WIN a new Macbook SitePoint 2017 Survey Yes, let's Do this It only takes 5 min

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;
Login or Create Account to Comment
Login Create Account
Get the most important and interesting stories in tech. Straight to your inbox, daily.Is it good?