$("li").each(function(index){
console.log( index +": "+$(this).text());});
A message is thus logged for each item in the list:
0: Mango
1: Book
Basic use
// arrayvar arr =['one','two','three','four'];
$.each(arr,function(index, value){
console.log(value);// Will stop running after "three"return(value !=='three');});// Outputs: one two three