# How to avoid this surprising Map behavior with external JS classes

**URL:** <https://discuss.kotlinlang.org/t/how-to-avoid-this-surprising-map-behavior-with-external-js-classes/9225>\
**Category:** JavaScript\
**Created:** [August 27, 2018, 3:18pm UTC](https://discuss.kotlinlang.org/t/how-to-avoid-this-surprising-map-behavior-with-external-js-classes/9225 "2018-08-27T15:18:37Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Svyatoslav.Kuzmich](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/svyatoslav.kuzmich/32/6748_2.png) [@Svyatoslav.Kuzmich](https://discuss.kotlinlang.org/u/Svyatoslav.Kuzmich)\
**Post date:** [October 2, 2018, 10:50am UTC](https://discuss.kotlinlang.org/t/how-to-avoid-this-surprising-map-behavior-with-external-js-classes/9225/2 "2018-10-02T10:50:53Z")

</div>

[Map](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html) is a particular Kotlin interface which is not mapped to any specific JavaScript type. You can’t cast a map-like JS object to kotlin.Map.

I can see couple of options:

1. Use external type with [Alternative to @nativeGetter](https://discuss.kotlinlang.org/t/alternative-to-nativegetter/9372)
2. Convert native object to HashMap [How to access native JS object as a Map\<String, Any\>?](https://discuss.kotlinlang.org/t/how-to-access-native-js-object-as-a-map-string-any/509)

---

_[View the full topic](https://discuss.kotlinlang.org/t/how-to-avoid-this-surprising-map-behavior-with-external-js-classes/9225)._
