javascript check if nested object property exists