// JS object add attribute conditionally const isActive = true; const obj = { id: 1, ...(isActive && { active: true }), }