Suggest an editImprove this articleRefine the answer for “some() in an array”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)The **`some()`** method is one of the boolean array methods in JavaScript. It checks whether at least one element satisfies the condition and returns `true` or `false`. **Key point:** as soon as the first matching element is found, the iteration stops.Shown above the full answer for quick recall.Answer (EN)ImageThe `some()` method is one of the boolean array methods in JavaScript. It checks **whether at least one element** satisfies the condition, and returns `true` **or** `false`. As soon as the first matching element is found, **the iteration stops**. ## Syntax ```javascript const result = array.some((element, index, array) => { return condition; }); ``` ### Callback parameters: | Argument | Description | | --- | --- | | `element` | The current array element | | `index` | The index of the current element | | `array` | The original array itself | ## Example 1. Checking if there are even numbers ```javascript const numbers = [1, 3, 5, 6, 7]; const hasEven = numbers.some(num => num % 2 === 0); console.log(hasEven); // true ``` > `some()` returned `true` because the array has at least one even number (`6`). ## Example 2. Checking if there are adult users ```javascript const users = [ { name: 'Tim', age: 17 }, { name: 'Alex', age: 21 }, { name: 'John', age: 16 } ]; const hasAdult = users.some(user => user.age >= 18); console.log(hasAdult); // true ``` > `some()` stops as soon as it finds the first adult user. ## Example 3. Checking for the presence of a value ```javascript const fruits = ['apple', 'banana', 'cherry']; const hasBanana = fruits.some(fruit => fruit === 'banana'); console.log(hasBanana); // true const hasMango = fruits.some(fruit => fruit === 'mango'); console.log(hasMango); // false ``` ## Example 4. Working with an empty array ```javascript console.log([].some(x => x > 0)); // false ``` > For an empty array `some()` **always returns** `false`, because there are no elements. ## Common errors 1. **Expecting an array instead of a boolean** ```javascript const result = arr.some(x => x > 10); console.log(result.length); // TypeError - some() returns true/false ``` 2. **A forgotten** `return` ```javascript arr.some(num => { num > 5 }); // always false ``` Correct: ```javascript arr.some(num => num > 5); // or arr.some(num => { return num > 5 }); ``` 3. **Confusing it with** `every()` - `some()` -> at least one element passes the condition - `every()` -> all elements pass the condition ## When to use `some()` | Goal | Is `some()` suitable | | --- | --- | | Check that **at least one** element matches the condition | Yes | | Check that **all** elements match the condition | No - use `every()` | | Find the element itself | No - use `find()` | | Get a list of matching elements | No - use `filter()` | ## Briefly: > `some()` returns `true` if **at least one array element** satisfies the condition. Formula to remember: `arr.some(condition)` -> `true | false` ## Example for clarity ```javascript const arr = [1, 2, 3, 4, 5]; console.log(arr.some(x => x > 3)); // true console.log(arr.some(x => x < 0)); // false ``` ## Comparison with similar methods | Method | Returns | Condition | Stops after the first match | | --- | --- | --- | --- | | **some()** | `true / false` | At least one element matches | Yes | | **every()** | `true / false` | All elements match | Yes (on the first `false`) | | **find()** | Element or `undefined` | At least one element matches | Yes | | **filter()** | New array | All matching elements | No | ## Example comparing `some()` and `every()` ```javascript const ages = [18, 22, 30, 16]; console.log(ages.some(age => age < 18)); // true -> there is at least one minor console.log(ages.every(age => age >= 18)); // false -> not everyone is an adult ```For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.