probably you need to check if vcardObj.photo[0] is not null or undefined