---
title: slot_count
description: Count the elements of an array object in a slot
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

### Behaviour

* Count the elements of an array in the specified slot
* Return the count

### Definition

<Tabs>
<TabItem label="C">
```c
int64_t slot_count (
    uint32_t slot_no
);
```


</TabItem>

<TabItem label="JavaScript">
```javascript
function slot_count(slotno: number): ErrorCode | number
```
</TabItem>
</Tabs>



### Example

<Tabs>
<TabItem label="C">
```c
slot_count(1); // assumes an array is slotted into slot=1
```
</TabItem>

<TabItem label="JavaScript">
```javascript
slot_count(1) // assumes an array is slotted into slot=1
```
</TabItem>
</Tabs>



### Parameters

<Tabs>
<TabItem label="C">
| Name     | Type      | Description     |
| -------- | --------- | --------------- |
| slot_no | uint32_t | The slot number |
</TabItem>

<TabItem label="JavaScript">
| Name   | Type   | Description     |
| ------ | ------ | --------------- |
| slotno | number | The slot number |
</TabItem>
</Tabs>

### Return Code

<Tabs>
<TabItem label="C">
| Type     | Description                                                                                                                                                                                                                                                                              |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| int64_t | <p>The number of elements inside the slotted array<br /><br />If negative, an error:<br /><code>DOESNT_EXIST</code><br />- the specified slot does not contain any object or it is an invalid slot<br /><br /><code>NOT_AN_ARRAY</code><br />- the specified slot does not contain an array object</p> |
</TabItem>

<TabItem label="JavaScript">
| Type                | Description                                    |
| ------------------- | ---------------------------------------------- |
| ErrorCode or number | Returns an error code or the count of entries. |
</TabItem>
</Tabs>

