Check if the result of the call is undefined

how can i check if the result for calling the javascript function is undefined?

I tried using

if( s.getNode(id1) != js.undefined) 

but fastOptJS will say:

scala.scalajs.js.Dynamic and scala.scalajs.js.UndefOr [Nothing] are unrelated: they are likely to always compare unequal

TIA

+7
source share
1 answer

This is a Scala system that is a little "too" useful.

For comparison with undefined you can use js.isUndefined :

 if (!js.isUndefined(s.getNode(id1))) 
+11
source share

All Articles