# getAttribute

## Description

Returns an object attribute.

## Input / Parameter

| Name      | Description                       | Input Type | Default | Options | Required |
| --------- | --------------------------------- | ---------- | ------- | ------- | -------- |
| object    | The object to get attribute from. | Object     | -       | -       | Yes      |
| attribute | The attribute to return.          | String     | -       | -       | Yes      |

## Output

| Description                     | Output Type |
| ------------------------------- | ----------- |
| Returns the selected attribute. | Object      |

## Example

In this example, we will get a value using an attribute of object.

### Step

1. Drag a `button` component into the canvas and open the `Action` tab. Select the `press` event of the button.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-6a7ffc60934619a06089ae4fc155350517722ba3%2FgetAttribute-step-1.png?alt=media)
2. Drag the `Log.write` function to the event flow and change the param type to function.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-5b56924e2e7b3788d5fb014296781694d150b143%2FgetAttribute-step-2.png?alt=media)
3. Put `Object.getAttribute` function inside the `value` parameter of the `Log.write` function. Fill in the parameters of the `Object.getAttribute` function.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-ab65c421c1fc5c2e5d62dedb185bdfe281cbae45%2FgetAttribute-step-3.png?alt=media)
4. For the object param, we will create a new object using `Conversion.toObject` function.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-2df84d0a6704d6398a91f66c173b4840f5186dd6%2FgetAttribute-step-4.png?alt=media)

### Result

1. This function will return the value if selected param exists.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-c8afe784a4ca6f493a2d0cf729603dbf2ddc548a%2FgetAttribute-step-result.png?alt=media)
