We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 8eaa582 + 9767692 commit 5932a1aCopy full SHA for 5932a1a
doc/interoperability/types.md
@@ -273,6 +273,21 @@ var o = new Object();
273
var x = f.call(o, 4);
274
{% endhighlight %}
275
276
+### JS functions with varargs
277
+
278
+In order to capture varargs from a JS function, create your own trait that
279
+extends `js.Function` or `js.ThisFunction`.
280
281
+{% highlight scala %}
282
+trait JsVarargsFn extends js.Function {
283
+ def apply(args: Any*): Unit
284
+}
285
286
+val f: JsVarargsFn = { args =>
287
+ println(s"This method was called with ${args.size} args.")
288
289
+{% endhighlight %}
290
291
## Dynamically typed interface: `js.Dynamic`
292
293
Because JavaScript is dynamically typed, it is not often practical, sometimes
0 commit comments