---
# System prepended metadata

title: Array

---

# Array

Option 1. Manually
- Create Array of Categories

Example:
```javascript
const Categories = ["Lunch", "Breakfast", ....];
```

Option 2. Automatic using Exist Array of objects
- Create Array from Exist Array using JavaScript functions(like: map, Set, spread operator and so on.)

Example
// Already
```javascript
const existArray = [Any Data];
```
// Creating New Array
Step 1. Create Array of Categories from Array pf Objects
```javascript
	const categories = existArray.map(ele => ele.category);
```
Step 2. Create Unique Array(Set is not give normal Array)
```javascript
	const categoriesunique = new Set(categories);
```
Step 3. Convert Set Array to Normal Array(use Spread operator)
```javascript
	const normalArray = [...categoriesunique];
```
Combine

```javascript
// ---------------------
// 
// // const uniqueList = [
//     ...new Set(
//     MenuAPI.map((curElem) => {
//         return curElem.category;
//     })
//     ), 
//     "All",
// ];
// 
// 
// Array of Objects
const MenuAPI = [
    {
        category: 'breakfast'
    },
    {
        category: 'lunch'
    }, {
        category: 'dinner'
    }
];

const list = MenuAPI.map(curElem => curElem.category);

// 1.
const uniqueList = [
    ...new Set(
    MenuAPI.map((curElem) => {
        return curElem.category;
    })
    ), 
    "All",
];
// 2.
const uniqueList = [
    ...new Set(
     ["Lunch", "Breacfast", "Lunch", "Dinner"]
    ), 
    "All",
];
// 3.
const uniqueList = [
    ...["Lunch", "Breacfast", "Dinner"], 
    "All",
];
// 4. 
const uniqueList = [
    "Lunch",
    "Breacfast",
    "Dinner", 
    "All",
];
```