// using destructuring to optionally add properties to object;constisEmployee=true;constperson={name:'xyz',age:28,...isEmployee?{// if isEmployee is true, it will destructure the employee objectemployeeId:'G548',department:'procurement'}:{},// else it will destructure this empty object};
Here's one more for you.
Super. Thanks!