# Menus

(menus)

## Overview

`Menus` in Servoy provide a scripting object for creating and managing menus (`JSMenu`, `JSMenuItem`) in applications. These objects facilitate dynamic or design-time menu configuration and interaction.

The `menus` object supports creating new menus using `createMenu(name)`, where the `name` must be a unique identifier. Existing menus can be retrieved using `getMenu(name)`, returning `null` if the specified menu does not exist. Additionally, all menus, whether created at runtime or design time, can be retrieved using `getMenus()`, which returns an array of available menus.

Menus enable developers to customize user navigation and application functionality dynamically or statically, supporting enhanced application experiences.

## **Returned Types**

[JSMenu](/reference/servoycore/dev-api/menus/jsmenu.md),[JSMenuItem](/reference/servoycore/dev-api/menus/jsmenuitem.md),

## Methods Summarized

| Type                                                    | Name                                 | Summary                                                             |
| ------------------------------------------------------- | ------------------------------------ | ------------------------------------------------------------------- |
| [JSMenu](/reference/servoycore/dev-api/menus/jsmenu.md) | [createMenu(name)](#createmenu-name) | Create a new, empty menu.                                           |
| [JSMenu](/reference/servoycore/dev-api/menus/jsmenu.md) | [getMenu(name)](#getmenu-name)       | Gets a menu by name.                                                |
| [Array](/reference/servoycore/dev-api/js-lib/array.md)  | [getMenus()](#getmenus)              | Returns all the menus, either created at design time or at runtime. |

## Methods Detailed

### createMenu(name)

Create a new, empty menu. Identifier must be unique among existing menus.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **name** the menu name (identifier)

**Returns:** [JSMenu](/reference/servoycore/dev-api/menus/jsmenu.md) the newly created menu with the specified name.

**Sample**

```js
var mnu = menus.createMenu('mymenu');
```

### getMenu(name)

Gets a menu by name. Returns null if not found.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **name** the menu name (identifier)

**Returns:** [JSMenu](/reference/servoycore/dev-api/menus/jsmenu.md) the menu with the specified name, or null if not found.

**Sample**

```js
var mnu = menus.getMenu('mymenu');
```

### getMenus()

Returns all the menus, either created at design time or at runtime.

**Returns:** [Array](/reference/servoycore/dev-api/js-lib/array.md) an array of all menus, created either at design time or runtime.

**Sample**

```js
var menus = menus.getMenus();
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/reference/servoycore/dev-api/menus.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
