# AddHostObjectToScript Sample

The following buttons interact with the `chrome.webview.hostObjects.sample` object. Open DevTools console to try running whatever code you like on this object.

## Get Property

Runs `await chrome.webview.hostObjects.sample.property`
`

`
Runs `chrome.webview.hostObjects.sync.sample.property`
`

`

## Set Property

Runs `chrome.webview.hostObjects.sample.property = value` which doesn't wait for the property to be set and returns immediately.
`

`
Runs `await chrome.webview.hostObjects.sample.setHostProperty("property", value)` which waits for the property to be set.
`

`
Runs `chrome.webview.hostObjects.sync.sample.property = value`
`

`

## Indexed Property

Runs `await chrome.webview.hostObjects.sample.indexedProperty[paramValue]` `

`
Runs `chrome.webview.hostObjects.sync.sample.indexedProperty[paramValue1] = paramValue2` `

`

## Invoke Method

Runs `await chrome.webview.hostObjects.sample.MethodWithParametersAndReturnValue(paramValue1, paramValue2)` `

`
Runs `chrome.webview.hostObjects.sync.sample.MethodWithParametersAndReturnValue(paramValue1, paramValue2)` `

`

## Invoke Callback

Runs `chrome.webview.hostObjects.sample.CallCallbackAsynchronously(() => { /* ... */ })` `

`

## Date Objects

Sets `chrome.webview.hostObjects.options.shouldSerializeDates = true` and then runs `chrome.webview.hostObjects.sample.dateProperty = new Date()`
Calls `chrome.webview.hostObjects.sample.createNativeDate()` to have the native object create and set the current time to the DateProperty `

`

## IFrame