JsValue

value class JsValue

One value from the engine. It costs nothing at runtime: the wrapper disappears and only the value itself is passed around.

The asX readers coerce the way JavaScript does, so asString() on the number 5 gives "5", the same answer String(5) gives in a script. Use type first when you need the exact kind.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

True for null and undefined, the two values optional chaining stops at.

Link copied to clipboard

True when this value is thenable, which is what await looks for.

Link copied to clipboard
Link copied to clipboard

Which kind of value this is.

Link copied to clipboard

What the typeof operator answers for this value.

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Throws unless this really is a BigInt. There is no coercion from a number, as in a script.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun asInt(): Int
Link copied to clipboard
fun asLong(): Long
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
inline fun <T> JsValue.convertTo(): T

Reads a JsValue as T, coercing the way JavaScript would where that makes sense.

Link copied to clipboard
fun toKotlin(): Any?

A plain Kotlin value, all the way down: Map for an object, List for an array, Double, String, Boolean, or null. A function stays a JsFunction, since it has no Kotlin twin.

Link copied to clipboard
open override fun toString(): String