thana
10/26/2020, 3:36 PMkeys()
method described here? https://discuss.kotlinlang.org/t/js-interop-for-in-and-for-of-loop-of-dynamic-objects/7507/4Big Chungus
10/26/2020, 3:40 PMthana
10/26/2020, 3:42 PMfor (i in object)
like i'd do in javascript 😕Big Chungus
10/26/2020, 3:50 PMinline fun asMap(jsObject: dynamic) = js("Object")
.entries(jsObject)
.unsafeCast<Array<Array<dynamic>>>()
.map {
it[0].unsafeCast<String>() to it[1]
}.toMap()
fun main() {
val x:dynamic = js("{name:'ok', otherName: 'notOk'}")
println(asMap(x).keys)
println(asMap(x).values)
for((k, v) in asMap(x)) {
println("Key: $k, Value: $v")
}
}
thana
10/26/2020, 3:57 PMBig Chungus
10/26/2020, 4:08 PMthana
10/26/2020, 4:14 PM