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

# Interface DOMTokenList

The **`DOMTokenList`** interface represents a set of space-separated tokens. Such a set is returned by Element.classList or HTMLLinkElement.relList, and many others.

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

interface DOMTokenList {  
    [length](#length): number;  
    [value](#value): string;  
    ["\[iterator\]"](#iterator-1)(): [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<string\>;  
    [add](#add-1)(...tokens: string\[\]): void;  
    [contains](#contains-1)(token: string): boolean;  
    [entries](#entries-1)(): [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<\[number, string\]\>;  
    [forEach](#foreach-1)(  
        callbackfn: (value: string, key: number, parent: DOMTokenList) \=> void,  
        thisArg?: any,  
    ): void;  
    [item](#item-1)(index: number): string | null;  
    [keys](#keys-1)(): [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<number\>;  
    [remove](#remove-1)(...tokens: string\[\]): void;  
    [replace](#replace-1)(token: string, newToken: string): boolean;  
    [supports](#supports-1)(token: string): boolean;  
    [toggle](#toggle-1)(token: string, force?: boolean): boolean;  
    [toString](#tostring-1)(): string;  
    [values](#values-1)(): [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<string\>;  
    \[index: number\]: string;  
}

#### Indexable

-   \[index: number\]: string
    

##### Index

### Properties[](#properties)

[length](#length) [value](#value)

### Methods[](#methods)

[\[iterator\]](#iterator) [add](#add) [contains](#contains) [entries](#entries) [forEach](#foreach) [item](#item) [keys](#keys) [remove](#remove) [replace](#replace) [supports](#supports) [toggle](#toggle) [toString](#tostring) [values](#values)

## Properties[](#properties-1)

### `Readonly`length[](#length)

length: number

The read-only **`length`** property of the DOMTokenList interface is an integer representing the number of objects stored in the object.

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

### value[](#value)

value: string

The **`value`** property of the DOMTokenList interface is a stringifier that returns the value of the list serialized as a string, or clears and sets the list to the given value.

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

## Methods[](#methods-1)

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

-   "\[iterator\]"(): [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<string\>[](#iterator-1)
    
    #### Returns [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<string\>
    

### add[](#add)

-   add(...tokens: string\[\]): void[](#add-1)
    
    The **`add()`** method of the DOMTokenList interface adds the given tokens to the list, omitting any that are already present.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/add)
    
    #### Parameters
    
    -   ...tokens: string\[\]
    
    #### Returns void
    

### contains[](#contains)

-   contains(token: string): boolean[](#contains-1)
    
    The **`contains()`** method of the DOMTokenList interface returns a boolean value — true if the underlying list contains the given token, otherwise false.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/contains)
    
    #### Parameters
    
    -   token: string
    
    #### Returns boolean
    

### entries[](#entries)

-   entries(): [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<\[number, string\]\>[](#entries-1)
    
    #### Returns [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<\[number, string\]\>
    

### forEach[](#foreach)

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

### item[](#item)

-   item(index: number): string | null[](#item-1)
    
    The **`item()`** method of the DOMTokenList interface returns an item in the list, determined by its position in the list, its index.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/item)
    
    #### Parameters
    
    -   index: number
    
    #### Returns string | null
    

### keys[](#keys)

-   keys(): [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<number\>[](#keys-1)
    
    #### Returns [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<number\>
    

### remove[](#remove)

-   remove(...tokens: string\[\]): void[](#remove-1)
    
    The **`remove()`** method of the DOMTokenList interface removes the specified tokens from the list.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/remove)
    
    #### Parameters
    
    -   ...tokens: string\[\]
    
    #### Returns void
    

### replace[](#replace)

-   replace(token: string, newToken: string): boolean[](#replace-1)
    
    The **`replace()`** method of the DOMTokenList interface replaces an existing token with a new token. If the first token doesn't exist, replace() returns false immediately, without adding the new token to the token list.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/replace)
    
    #### Parameters
    
    -   token: string
    -   newToken: string
    
    #### Returns boolean
    

### supports[](#supports)

-   supports(token: string): boolean[](#supports-1)
    
    The **`supports()`** method of the DOMTokenList interface returns true if a given token is in the associated attribute's supported tokens. This method is intended to support feature detection.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/supports)
    
    #### Parameters
    
    -   token: string
    
    #### Returns boolean
    

### toggle[](#toggle)

-   toggle(token: string, force?: boolean): boolean[](#toggle-1)
    
    The **`toggle()`** method of the DOMTokenList interface removes an existing token from the list and returns false. If the token doesn't exist it's added and the function returns true.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/toggle)
    
    #### Parameters
    
    -   token: string
    -   `Optional`force: boolean
    
    #### Returns boolean
    

### toString[](#tostring)

-   toString(): string[](#tostring-1)
    
    #### Returns string
    

### values[](#values)

-   values(): [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<string\>[](#values-1)
    
    #### Returns [ArrayIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ArrayIterator/)<string\>
