every()與some()方法都是JS中數組的迭代方法。
every()是對數組中每一項運行給定函數,如果該函數對每一項返回true,則返回true。
some()是對數組中每一項運行給定函數,如果該函數對任一項返回true,則返回true。
var arr = [ 1, 2, 3, 4, 5, 6 ]; console.log( arr.some( function( item, index, array ){ console.log( 'item=' + item + ',index='+index+',array='+array ); return item > 3; })); //結果: true console.log( arr.every( function( item, index, array ){ console.log( 'item=' + item + ',index='+index+',array='+array ); return item > 3; })); //結果: false