any

object any

Much unsafeness here. Assumes you know what you are doing.

class Object
trait Matchable
class Any

Extensions

Extensions

extension [A <: Int | Float | Double](a: A)
def toLocaleString(locale: UndefOr[String | Array[String]], options: UndefOr[Object]): String

Intended for directly mapped scala types, not scala.Any in general. Know what you are doing!!! Very dangerous!

Intended for directly mapped scala types, not scala.Any in general. Know what you are doing!!! Very dangerous!

extension [T <: Any](a: T)
@targetName("asJSAny")
def as[A]: A

.asInstanceOf[T] but shorter. Very dangerous!

.asInstanceOf[T] but shorter. Very dangerous!

def asBoolean: Boolean

All of these are unsafe.

All of these are unsafe.

def asDict[A]: Dictionary[A]

All of these are unsafe.

All of these are unsafe.

def asDouble: Double

All of these are unsafe.

All of these are unsafe.

def asDyn: Dynamic

All of these are unsafe.

All of these are unsafe.

def asFloat: Float

All of these are unsafe.

All of these are unsafe.

def asInt: Int

All of these are unsafe.

All of these are unsafe.

def asJSArray[A]: Array[A]

All of these are unsafe.

All of these are unsafe.

def asJSDate: Date

All of these are unsafe.

All of these are unsafe.

def asJSDict[A]: Dictionary[A]

All of these are unsafe.

All of these are unsafe.

def asJSDyn: Dynamic

All of these are unsafe.

All of these are unsafe.

def asJSObj: Object

All of these are unsafe.

All of these are unsafe.

def asJSObjSub[A <: Object]: A

Assume a subclass of js.Object.

Assume a subclass of js.Object.

def asJSObject: Object

All of these are unsafe.

All of these are unsafe.

def asJsAny: Any

If T is js.Any, this may be redundent.

If T is js.Any, this may be redundent.

def asJsArray[A]: Array[A]

All of these are unsafe.

All of these are unsafe.

def asJsObj: Object

All of these are unsafe.

All of these are unsafe.

def asJson: String

All of these are unsafe.

All of these are unsafe.

def asNullBoolean: Boolean | Null

All of these are unsafe.

All of these are unsafe.

def asNullDouble: Double | Null

All of these are unsafe.

All of these are unsafe.

def asNullFloat: Float | Null

All of these are unsafe.

All of these are unsafe.

def asNullInt: Int | Null

All of these are unsafe.

All of these are unsafe.

def asNullJSDate: Date

All of these are unsafe.

All of these are unsafe.

def asNullString: String

All of these are unsafe.

All of these are unsafe.

def asNumber: Number

All of these are unsafe.

All of these are unsafe.

def asString: String

All of these are unsafe.

All of these are unsafe.

def asUndefBoolean: UndefOr[Boolean]

All of these are unsafe.

All of these are unsafe.

def asUndefDouble: UndefOr[Double]

All of these are unsafe.

All of these are unsafe.

def asUndefFloat: UndefOr[Float]

All of these are unsafe.

All of these are unsafe.

def asUndefInt: UndefOr[Int]

All of these are unsafe.

All of these are unsafe.

def asUndefJSDate: UndefOr[Date]

All of these are unsafe.

All of these are unsafe.

def asUndefNullBoolean: UndefOr[Boolean | Null]

All of these are unsafe.

All of these are unsafe.

def asUndefNullDouble: UndefOr[Double | Null]

All of these are unsafe.

All of these are unsafe.

def asUndefNullFloat: UndefOr[Float | Null]

All of these are unsafe.

All of these are unsafe.

def asUndefNullInt: UndefOr[Int | Null]

All of these are unsafe.

All of these are unsafe.

def asUndefNullJSDate: UndefOr[Date]

All of these are unsafe.

All of these are unsafe.

def asUndefNullString: UndefOr[String]

All of these are unsafe.

All of these are unsafe.

def asUndefString: UndefOr[String]

All of these are unsafe.

All of these are unsafe.

def filterNull: UndefOr[T]

Internal null values become undefined.

Internal null values become undefined.

def maybeNull: T | Null

Convert T => T|Null.

Convert T => T|Null.

def toNonNullOption: Option[T]

If value is null or undefined be None, else Some.

If value is null or undefined be None, else Some.

def toNonNullUndefOr: UndefOr[T]

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".

def toStringJs: String

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.

@targetName("toTruthyJSAny")
def toTruthy: Boolean

Equivalent !!x for some javascript value x.

Equivalent !!x for some javascript value x.

def toTruthyOption: Option[T]

Unlike Option use truthiness to determine if the value should be None.

Unlike Option use truthiness to determine if the value should be None.

def toTruthyUndefOr: UndefOr[T]

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