2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-09-29 19:01:10 +02:00
|
|
|
title: Attributes.getAsArray()
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 19:01:10 +02:00
|
|
|
The `Attributes.getAsArray()` method will return an array with the value of
|
|
|
|
attribute stored under `key`, or `false` if it's not set.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
|
|
|
array attributes.getAsArray(string key)
|
|
|
|
```
|
|
|
|
|
2022-09-29 19:01:10 +02:00
|
|
|
## Example
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
2022-09-29 19:01:10 +02:00
|
|
|
const attr = new Attributes()
|
|
|
|
.add('class', 'classA')
|
|
|
|
.add('class', 'classB')
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 19:01:10 +02:00
|
|
|
const class = attr.getAsArray('class')
|
|
|
|
// class now holds: [ "classA", "classB" ]
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|