---
description: Search method of array helpers
---

# $.array.search

Search method is capable of seaching all the data from array of objects by just typing some characters. Search method also allow multiple searches at one with multiple queries.

```
$.array.search(fromArray, ...textQuery*)

// Example:
const fromArray = [
  { id: '1', name: 'Hanbal Tedir', office: 'Jakarta', age: 30 },
  { id: '2', name: 'Dawoud Tedir', office: 'Medan', age: 27 },
  { id: '3', name: 'Harist Tedir', office: 'Sigli', age: 15 },
  { id: '4', name: 'Tedir Ghazali', office: 'Banda Aceh', age: 29 },
  { id: '5', name: 'Hanbal Usman', office: 'Langsa', age: 27 },
  { id: '6', name: 'Dawoud Usman', office: 'Pidie', age: 25 },
  { id: '7', name: 'Harist Usman', office: 'Samarinda', age: 18 },
  { id: '8', name: 'Ghazali Usman', office: 'Balikpapan', age: 45 },
  { id: '9', name: 'Bukhari Usman', office: 'Makassar', age: 44 },
  { id: '10', name: 'Boyhaki Usman', office: 'Jaya Pura', age: 35 },
  { id: '11', name: 'Zulkifli Usman', office: 'Manado', age: 56 },
  { id: '12', name: 'Teuku Usman', office: 'Ternate', age: 58 }
]
$.array.search(fromArray, 'ba')
//=> [
//  { id: '1', name: 'Hanbal Tedir', office: 'Jakarta', age: 30 },
//  { id: '4', name: 'Tedir Ghazali', office: 'Banda Aceh', age: 29 },
//  { id: '5', name: 'Hanbal Usman', office: 'Langsa', age: 27 },
//  { id: '8', name: 'Ghazali Usman', office: 'Balikpapan', age: 45 }
//]
```

Or if you guys want to search the array of objects by multiple queries or text, or you may want to search array only with string or number in it, this helper also support that.

```
$.array.search(fromArray, 'oud', 'lan')
//=> [
//  { id: '2', name: 'Dawoud Tedir', office: 'Medan', age: 27 },
//  { id: '6', name: 'Dawoud Usman', office: 'Pidie', age: 25 },
//  { id: '5', name: 'Hanbal Usman', office: 'Langsa', age: 27 }
//]

// search array of strings or numbers
const strings = ['Medan', 'Langsa', 'Banda Aceh', 'Pidie', 'Lamda']
$.array.search(strings, 'da')
//=> ['Medan', 'Banda Aceh', 'Lamda']
```

Alga.js also provide a helper for searching only from some object properties and also support multiple searches as well.

```
$.array.searchBy(fromArray, queriesInArray, propsInArray)

// Example:
$.array.searchBy(fromArray, ['dan', 'han'], ['name', 'office'])
//=> [
//  { id: '2', name: 'Dawoud Tedir', office: 'Medan', age: 27 },
//  { id: '1', name: 'Hanbal Tedir', office: 'Jakarta', age: 30 },
//  { id: '5', name: 'Hanbal Usman', office: 'Langsa', age: 27 }
//]
```
