How to check if js.Any value is a number in ScalaJS
1 answer
This question raises 2 points.
-
js. Generally should be avoided. Prefer to use scala instead. Any
-
Anyway, if you are stuck with js.Any, somehow raise it to scala. Anyone then do the usual pattern matching:
def isNumber (x: js.Any): Boolean = {
(x: Any) match {
case x: Double => true
case _ => false
}
}
+4
source to share