javascript call function if not undefined