javascript array get first element if exists