How can I access Js Array in Kotlin file ?
# javascript
r
How can I access Js Array in Kotlin file ?
t
the same way like in kotlin i.e.
someArray[someKey]
maybe you have to make
someArray
dynamic
depending on what type the kotlin compiler thinks
someArray
has
r
Array of js can do have push,pop functions. Iwant something like this
Copy code
val stack = ArrayOfJs(); stack.pop()
t
val stack = js("[]")
does the job - i don't know if there is a special type available in kotlin/js but using those function on a
dynamic
values works, too
r
thanks looking for this only !!
g
You also can use Kotlin Mutable list, there is no push and pop, but you can easily add them as extensions
b
better/idiomatic way in Kotlin is using
MutableList
but if really need modify array please tell us 🙂
anyway Array in Kotlin is JS Array at runtime, so, you can add own extension function and implement it using
dynamic
type