How to use ArrayList outside of kotlin, in the js?...
# javascript
l
How to use ArrayList outside of kotlin, in the js? I am unable to call
get
, external class should help?
k
You better give up
You can create a wrapper that exposes access to ArrayList via methods marked as
JsName
You can open kotlin.js and see which methods are actually there.
Or you can write a simple program that works with ArrayList and see which methods are actually called
Copy code
var mutableListOf = Kotlin.kotlin.collections.mutableListOf_i5x0yv$;
  var println = Kotlin.kotlin.io.println_s8jyv4$;
  function main(args) {
    var list = mutableListOf([1, 2, 3]);
    list.add_11rb$(4);
    println(list.get_za3lpa$(0));
    println(list.size);
  }
l
Why
Copy code
@JsName("kget")
fun <V> ArrayList<V>.kget(key: Int): V? = get(key)
not works?
is
get_za3lpa$
same in each browser? ))
k
Yes
Because extension function is not copied to prototype
👍 1
It's de-facto static function with first parameter taking call receiver
l
Then I'll use get_za3lpa$. I am going to rewrite js to kotlin, so get_za3lpa$ will be replaced