Check that a value is a valid index into an indexable object.
Throws if index is not a valid index into indexable.
An indexable object is one that has a length
and a and index-operator
[]
that accepts an index if 0 <= index < length
.
If length is provided, it is used as the length of the indexable object,
otherwise the length is found as indexable.length
.