Anton
Anton

Reputation: 1126

Pass a JavaScript array to a function in Scala.js

Using import js.Dynamic.{ global => g} I am able to access the MathJax library as g.MathJax, but I can not find how to pass a function argument when calling a function from MathJax. I currently have the following: g.MathJax.Hub.Queue(["Typeset", g.MathJax.Hub]) which results in illegal start of simple expression which is of course because I am using square brackets, but I don't know how to properly pass the array with scalajs.

Upvotes: 2

Views: 215

Answers (1)

sjrd
sjrd

Reputation: 22085

A JavaScript array is typed as a js.Array in Scala.js. So the square brackets "constructor" for arrays can be written with js.Array(...), like this:

import scala.scalajs.js

g.MathJax.Hub.Queue(js.Array("Typeset", g.MathJax.Hub))

More information on what Scala.js correspond to what JavaScript can be found in the documentation.

Upvotes: 2

Related Questions