Someone please correct me if i'm wrong, but AFAIK the following is true:
hasOwnProperty
"inherited" from Object
hasOwnProperty
can check if anything exists at an array index.So, as long as the above is true, you can simply:
const arrayHasIndex = (array, index) => Array.isArray(array) && array.hasOwnProperty(index);
usage:
arrayHasIndex([1,2,3,4],4);
outputs: false
arrayHasIndex([1,2,3,4],2);
outputs: true