mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
cd2bb8333d
While there are some browser tests, Node.js is just a lot better for testing this kind of stuff because it's much faster and we don't need a browser for this.
18 lines
339 B
Go
18 lines
339 B
Go
package main
|
|
|
|
import "syscall/js"
|
|
|
|
func main() {
|
|
js.Global().Call("setCallback", js.FuncOf(func(this js.Value, args []js.Value) any {
|
|
println("inside callback! parameters:")
|
|
sum := 0
|
|
for _, value := range args {
|
|
n := value.Int()
|
|
println(" parameter:", n)
|
|
sum += n
|
|
}
|
|
return sum
|
|
}))
|
|
js.Global().Call("callCallback")
|
|
}
|