javascript check if nested property exists