right-indexof
return the index of an item in an array starting from the right side
example
var rindex = ;var xs = 'a' 'y' 'b' 'x' 'a' 'y' ;console;console;console;console;console;
output:
rindex("a") = 4
rindex("b") = 2
rindex("x") = 3
rindex("y") = 5
rindex("z") = -1
methods
var rindex =
var ix = rindex(xs, x)
Return the index ix
of the element x
in the array xs
starting from the
right-hand side (starting at xs.length-1), returning the first element that is
strictly equal (===
) to the item x
.
If x
is not found in xs
, return -1
.
install
With npm do:
npm install right-indexof
license
MIT