---
title: "arrayFindBinary"
canonical: "https://support.appfire.com/space/PSCONF/15302844/arrayFindBinary"
format: markdown
---
> Macro (aura-html)

> Macro (table-plus)
> 
> |  |  |  |  |
> | --- | --- | --- | --- |
> | **Syntax** | arrayFindBinary(arrayName, element) | **Package** | array |
> | **Alias** |  | **Pkg Usage** | binaryFind(arrayName, element) |

## Description

> Macro (excerpt)
> 
> Binary search on sorted array. If the element is not found, returns -1.

Binary search on sorted array. If the element is not found, returns -1.

## Parameters

> Macro (table-plus)
> 
> | Parameter name | Type | Required | Description |
> | --- | --- | --- | --- |
> | arrayName | Array | Yes | Array. |
> | element | type of array element | Yes | Element to find in the array. |

## Return Type

**Number**

## Example

```javascript
return arrayFindBinary(arraySort(usersInGroups({"jira-users"}), false), "admin");
```

The result of the routine is the index of the searched element in the array returned by [arraySort](https://appfire.atlassian.net/wiki/spaces/PSCONF/pages/15302869). If the array contains duplicates, the routine returns the index of the first occurrence of the searched element.

> ⚠️ Binary search should be used only for sorted arrays.

## See also

> Macro (contentbylabel)