check if object is not undefined javascript