# How to access native JS object as a Map\<String, Any\>?

**URL:** <https://discuss.kotlinlang.org/t/how-to-access-native-js-object-as-a-map-string-any/509>\
**Category:** JavaScript\
**Created:** [August 15, 2014, 11:28pm UTC](https://discuss.kotlinlang.org/t/how-to-access-native-js-object-as-a-map-string-any/509 "2014-08-15T23:28:38Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Lamartio](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@Lamartio](https://discuss.kotlinlang.org/u/Lamartio)\
**Post date:** [May 29, 2020, 6:33pm UTC](https://discuss.kotlinlang.org/t/how-to-access-native-js-object-as-a-map-string-any/509/8 "2020-05-29T18:33:24Z")

</div>

Another way is just to iterate over the key-value pairs of a JS object:

```auto
fun entriesOf(jsObject: dynamic): List<Pair<String, Any?>> =
    (js("Object.entries") as (dynamic) -> Array<Array<Any?>>)
        .invoke(jsObject)
        .map { entry -> entry[0] as String to entry[1] }

fun mapOf(jsObject: dynamic): Map<String, Any?> =
    entriesOf(jsObject).toMap()

```

---

_[View the full topic](https://discuss.kotlinlang.org/t/how-to-access-native-js-object-as-a-map-string-any/509)._
