Is there a nice way to loop on only the first 3 items of a json object using the jquery each loop?
I am thinking of an equivalent of the .slice(start,end) function.
var data = [
{"Id": 10004, "PageName": "club"},
{"Id": 10040, "PageName": "qaz"},
{"Id": 10059, "PageName": "ee"},
{"Id": 10089, "PageName": "dd"},
{"Id": 10095, "PageName": "hh"}
];
$.each(data, function(i, item) {
alert(item.PageName);
// somehow break at item 3
});
each stops when you return false.
From the docs: