---
title: "Helpers/array"
---
# Helpers/array

### asArray()

**asArray**\<`T`\>(`a`): `T`[]

Defined in: [src/core/helpers/array/as-array.ts:21](https://github.com/xdan/jodit/blob/main/src/core/helpers/array/as-array.ts#L21)

Always return Array
```javascript
Jodit.modules.Helpers.asArray('test') // ['test']
Jodit.modules.Helpers.asArray(['test']) // ['test']
Jodit.modules.Helpers.asArray(1) // [1]
```

#### Type Parameters

| Type Parameter |
| ------ |
| `T` |

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `a` | `T` \| `T`[] |

#### Returns

`T`[]

***

### splitArray()

Return an array from string or array
```javascript
Jodit.modules.Helpers.splitArray('1,2,3') // ['1', '2', '3']
Jodit.modules.Helpers.splitArray(['1', '2', '3']) // ['1', '2', '3']
```

#### Call Signature

**splitArray**(`a`): `string`[]

Defined in: [src/core/helpers/array/split-array.ts:11](https://github.com/xdan/jodit/blob/main/src/core/helpers/array/split-array.ts#L11)

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `a` | `string` |

##### Returns

`string`[]

#### Call Signature

**splitArray**\<`T`\>(`a`): `T`

Defined in: [src/core/helpers/array/split-array.ts:13](https://github.com/xdan/jodit/blob/main/src/core/helpers/array/split-array.ts#L13)

##### Type Parameters

| Type Parameter |
| ------ |
| `T` *extends* `any`[] |

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `a` | `T` |

##### Returns

`T`

#### Call Signature

**splitArray**\<`T`\>(`a`): `string`[] \| `T`

Defined in: [src/core/helpers/array/split-array.ts:15](https://github.com/xdan/jodit/blob/main/src/core/helpers/array/split-array.ts#L15)

##### Type Parameters

| Type Parameter |
| ------ |
| `T` *extends* `any`[] |

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `a` | `string` \| `T` |

##### Returns

`string`[] \| `T`

***

### toArray()

Always return Array. It's a safe polyfill for [Array.from](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) method
In certain scenarios (such as with Joomla Mootools), Array.from may be substituted with a less optimal implementation
```javascript
Jodit.modules.Helpers.toArray('123') // ['1', '2', '3']
Jodit.modules.Helpers.toArray(['test']) // ['test']
Jodit.modules.Helpers.toArray(1) // []
```

#### Call Signature

**toArray**\<`T`\>(`arrayLike`): `T`[]

Defined in: [src/core/helpers/array/to-array.ts:23](https://github.com/xdan/jodit/blob/main/src/core/helpers/array/to-array.ts#L23)

Creates an array from an array-like object.

##### Type Parameters

| Type Parameter |
| ------ |
| `T` |

##### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `arrayLike` | `ArrayLike`\<`T`\> | An array-like object to convert to an array. |

##### Returns

`T`[]

#### Call Signature

**toArray**\<`T`, `U`\>(`arrayLike`, `mapfn`, `thisArg?`): `U`[]

Defined in: [src/core/helpers/array/to-array.ts:23](https://github.com/xdan/jodit/blob/main/src/core/helpers/array/to-array.ts#L23)

Creates an array from an iterable object.

##### Type Parameters

| Type Parameter |
| ------ |
| `T` |
| `U` |

##### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `arrayLike` | `ArrayLike`\<`T`\> | An array-like object to convert to an array. |
| `mapfn` | (`v`, `k`) => `U` | A mapping function to call on every element of the array. |
| `thisArg?` | `any` | Value of 'this' used to invoke the mapfn. |

##### Returns

`U`[]

#### Call Signature

**toArray**\<`T`\>(`iterable`): `T`[]

Defined in: [src/core/helpers/array/to-array.ts:23](https://github.com/xdan/jodit/blob/main/src/core/helpers/array/to-array.ts#L23)

Creates an array from an iterable object.

##### Type Parameters

| Type Parameter |
| ------ |
| `T` |

##### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `iterable` | [`Iterable`](https://www.typescriptlang.org/docs/handbook/iterators-and-generators.html#iterable-interface)\<`T`, `any`, `any`\> \| `ArrayLike`\<`T`\> | An iterable object to convert to an array. |

##### Returns

`T`[]

#### Call Signature

**toArray**\<`T`, `U`\>(`iterable`, `mapfn`, `thisArg?`): `U`[]

Defined in: [src/core/helpers/array/to-array.ts:23](https://github.com/xdan/jodit/blob/main/src/core/helpers/array/to-array.ts#L23)

Creates an array from an iterable object.

##### Type Parameters

| Type Parameter |
| ------ |
| `T` |
| `U` |

##### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `iterable` | [`Iterable`](https://www.typescriptlang.org/docs/handbook/iterators-and-generators.html#iterable-interface)\<`T`, `any`, `any`\> \| `ArrayLike`\<`T`\> | An iterable object to convert to an array. |
| `mapfn` | (`v`, `k`) => `U` | A mapping function to call on every element of the array. |
| `thisArg?` | `any` | Value of 'this' used to invoke the mapfn. |

##### Returns

`U`[]
