Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions doc/interoperability/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,21 @@ var o = new Object();
var x = f.call(o, 4);
{% endhighlight %}

### JS functions with varargs

In order to capture varargs from a JS function, create your own trait that
extends `js.Function` or `js.ThisFunction`.

{% highlight scala %}
trait JsVarargsFn extends js.Function {
def apply(args: Any*): Unit
}

val f: JsVarargsFn = { args =>
println(s"This method was called with ${args.size} args.")
}
{% endhighlight %}

## Dynamically typed interface: `js.Dynamic`

Because JavaScript is dynamically typed, it is not often practical, sometimes
Expand Down