---
title: "CustomStateSet | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

# Interface CustomStateSet

The **`CustomStateSet`** interface of the Document Object Model stores a list of states for an autonomous custom element, and allows states to be added and removed from the set.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomStateSet)

interface CustomStateSet {  
    ["\[toStringTag\]"](#tostringtag): string;  
    [size](#size): number;  
    ["\[iterator\]"](#iterator-1)(): [SetIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SetIterator/)<string\>;  
    [add](#add-1)(value: string): this;  
    [clear](#clear-1)(): void;  
    [delete](#delete-1)(value: string): boolean;  
    [entries](#entries-1)(): [SetIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SetIterator/)<\[string, string\]\>;  
    [forEach](#foreach-1)(  
        callbackfn: (  
            value: string,  
            key: string,  
            parent: CustomStateSet,  
        ) \=> void,  
        thisArg?: any,  
    ): void;  
    [has](#has-1)(value: string): boolean;  
    [keys](#keys-1)(): [SetIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SetIterator/)<string\>;  
    [values](#values-1)(): [SetIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SetIterator/)<string\>;  
}

#### Hierarchy

-   Set<string\>
    -   CustomStateSet

##### Index

### Properties[](#properties)

[\[toStringTag\]](#tostringtag) [size](#size)

### Methods[](#methods)

[\[iterator\]](#iterator) [add](#add) [clear](#clear) [delete](#delete) [entries](#entries) [forEach](#foreach) [has](#has) [keys](#keys) [values](#values)

## Properties[](#properties-1)

### `Readonly`\[toStringTag\][](#tostringtag)

"\[toStringTag\]": string

### `Readonly`size[](#size)

size: number

#### Returns[](#returns)

the number of (unique) elements in Set.

## Methods[](#methods-1)

### \[iterator\][](#iterator)

-   "\[iterator\]"(): [SetIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SetIterator/)<string\>[](#iterator-1)
    
    Iterates over values in the set.
    
    #### Returns [SetIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SetIterator/)<string\>
    

### add[](#add)

-   add(value: string): this[](#add-1)
    
    Appends a new element with a specified value to the end of the Set.
    
    #### Parameters
    
    -   value: string
    
    #### Returns this
    

### clear[](#clear)

-   clear(): void[](#clear-1)
    
    Removes all elements from the Set.
    
    #### Returns void
    

### delete[](#delete)

-   delete(value: string): boolean[](#delete-1)
    
    Removes a specified value from the Set.
    
    #### Parameters
    
    -   value: string
    
    #### Returns boolean
    
    Returns true if an element in the Set existed and has been removed, or false if the element does not exist.
    

### entries[](#entries)

-   entries(): [SetIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SetIterator/)<\[string, string\]\>[](#entries-1)
    
    Returns an iterable of \[v,v\] pairs for every value `v` in the set.
    
    #### Returns [SetIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SetIterator/)<\[string, string\]\>
    

### forEach[](#foreach)

-   forEach(  
        callbackfn: (value: string, key: string, parent: CustomStateSet) \=> void,  
        thisArg?: any,  
    ): void[](#foreach-1)
    
    #### Parameters
    
    -   callbackfn: (value: string, key: string, parent: CustomStateSet) \=> void
    -   `Optional`thisArg: any
    
    #### Returns void
    

### has[](#has)

-   has(value: string): boolean[](#has-1)
    
    #### Parameters
    
    -   value: string
    
    #### Returns boolean
    
    a boolean indicating whether an element with the specified value exists in the Set or not.
    

### keys[](#keys)

-   keys(): [SetIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SetIterator/)<string\>[](#keys-1)
    
    Despite its name, returns an iterable of the values in the set.
    
    #### Returns [SetIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SetIterator/)<string\>
    

### values[](#values)

-   values(): [SetIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SetIterator/)<string\>[](#values-1)
    
    Returns an iterable of values in the set.
    
    #### Returns [SetIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SetIterator/)<string\>
