javascript array check if index exists