I'm using "syscall/js" to export a Go-WebAssembly function to JavaScript. The function in Go is required to be like this:
func x ( this js.Value, args []js.Value ) interface{}
Now I want to pass a 2-d array from JavaScript to Go. I receive it ( which is [][]byte in JavaScript ) as args[0], it is simply a js.Value which don't support indexing like args[0][i], so I can't process it further like
buffer := make([][]byte, args[0].Length())
for i:=0; i<len(buffer); i++{
js.CopyBytesToGo(buffer[i], args[0][i])
}
The Error info will be:
invalid operation: args[0][i] (type js.Value does not support indexing)
What can I do to receive args[0] properly as a 2-d array []js.Value? I've tried to receive args[0] with an interface{} but it won't work.