var ary = [ 52, 97 ]; $.each(ary, function( index, value ) { console.log( index + ": " + value ); });
結果
針對Object進行
var ary = {}; ary["aaa"] = "123"; ary["bbb"] = "456"; $.each(ary, function( index, value ) { console.log( index + ": " + value ); });
結果
break 效果 (return false)
var ary = [ 52, 97 ]; $.each(ary, function( index, value ) { if(index == 1) return false; console.log( index + ": " + value ); });
結果
var ary = [ 52, 97 ,30,20]; $.each(ary, function( index, value ) { if(index == 1) return true; console.log( index + ": " + value ); });
結果
沒有留言:
張貼留言