javascript check if defined and not null