Ideally, a common interface or type would allow code compiled to both JS and JVM to make use of a fast Array type without the need to use a buffer. Presumably the fastest array type in Scala.js is a js.Array (resizable) and on the JVM it is the Array (not resizable), so Array does not really work here.
It could be that type classes are the way to go here, but that may be overkill. Still, if it is the best solution, I'd be interested to know.
Another possible solution that comes to mind, that would require a fair bit of collaboration though maybe not a lot of effort, would be to get the new Scala Collections API to agree on an API for just this purpose (although it would not be limited to libraries used on the JS and JVM). It could possibly end up being a restricted view of an existing Array implementation in Scala collections for the JVM, assuming no performance penalties would be incurred with such an approach.
scala.collection.Seqis a common interface forjs.Arrayandscala.Array. What else do you want?scala.collection.mutable.Buffer(andArrayBuilder) are backed by ajs.Array.js.Array, but by developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…scala.scalajs.js.typedarray.ArrayBuffer? That is not backed by a JS ArrayBuffer, it is a JS ArrayBuffer. If you need an interoperable type that is backed by a typed array (in JS), you can use a direct ByteBuffer. See TypedArrayBuffer for access.