getDefaultValue

fun getDefaultValue(obj: Scriptable, typeHint: KClass<*>?): Any?

OrdinaryToPrimitive: tries toString and valueOf in the order the hint asks for, and takes the first one that gives back a primitive.