JS menambahkan alat peraga ke obj secara kondisional

const isOnline=true;
const user={
    id:6,
    name:'Frank',
    ...(isOnline &&{active:true}),
}
//{id:6,name:'Frank',active:true}
console.log(user);l
Quaint Quelea