ternary operator check if null javascript