看看下面的代码是否有帮助function processLongArray() { var myLongArray = [{ "username": "active" }, { "username": "active" }, { "username": "inactive" }]; // and many more elements in the array var count = 0; var targetCount = 1; // stop after this number of objects for (var i = 0; i < myLongArray.length; i++) { var arrayItem = myLongArray[i]; // condition to test if the arrayItem is considered in count // If no condition needed, we can directly increment the count if (arrayItem.username === "active") { count++; } if (count >= targetCount) { console.log("OK we are done! @ " + count); return count; // or any other desired value } }}processLongArray();