javascript add property to object if not undefined