any
Much unsafeness here. Assumes you know what you are doing.
Extensions
Extensions
.asInstanceOf[T]
but shorter. Very dangerous!
.asInstanceOf[T]
but shorter. Very dangerous!
If value is null or undefined be undefined, otherwise defined. Could be called "filterNull".
If value is null or undefined be undefined, otherwise defined. Could be called "filterNull".
Call the toString method after casting to js.Any. Not sure casting makes any difference though.
Call the toString method after casting to js.Any. Not sure casting makes any difference though.
Equivalent !!x
for some javascript value x.
Equivalent !!x
for some javascript value x.
Unlike Option
use truthiness to determine if the value should be None.
Unlike Option
use truthiness to determine if the value should be None.
Wow, a mouthful! If its a javascript truthy=true, its defined, otherwise undef. Takes into account 0, "" and [] javascript idioms i.e. takes into account the FP zero.
Wow, a mouthful! If its a javascript truthy=true, its defined, otherwise undef. Takes into account 0, "" and [] javascript idioms i.e. takes into account the FP zero.
- Example
val s = "" // s.toTruthyUndefOr[String] => js.undefined val s = "blah" // s.toTurthyUndefOr[String] => defined "blah" val n = 0 // n.toTruthyUndefOr[Int] => js.undefined val n1 = 1 // n1.toTruthyUndefOr[Int] => defined 1