toIndex

fun toIndex(value: Any?): Int

ToIndex: a non-negative integer that fits the safe range, or a RangeError.