trait AnyOps[T] extends AnyRef
- Alphabetic
- By Inheritance
- AnyOps
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Concrete Value Members
- def as[T]: T
.asInstanceOf[T]
but shorter..asInstanceOf[T]
but shorter. Very dangerous! - def asBoolean: Boolean
- def asDouble: Double
- def asDyn: Dynamic
- def asInt: Int
- def asJsAny: Any
If T is js.Any, this may be redundent.
- def asJsArray[A]: Array[A]
- def asJsObj: Object
- def asJson: String
- def asNumber: Number
- def asString: String
- def filterNull: UndefOr[T]
Internal null values become undefined.
- def toNonNullOption: Option[T]
If value is null or undefined be None, else Some.
- def toNonNullUndefOr: UndefOr[T]
If value is null or undefined be undefined, otherwise defined.
If value is null or undefined be undefined, otherwise defined. Could be called "filterNull".
- def toStringJs: String
Call the toString method after casting to js.Any.
Call the toString method after casting to js.Any. Not sure casting makes any difference though.
- def toTruthy: Boolean
Equivalent
!!x
for some javascript value x. - def toTruthyUndefOr: UndefOr[T]
Wow, a mouthful! If its a javascript truthy=true, its defined, otherwise undef.
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.
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
Example: