151. Conditionally Change Object in JavaScript (jaketrent.com)
Here's how to conditionally update an object in JavaScript.Best wayThis is the best method for conditionally updating an object for two reasons:It's copy-on-write, avoiding mutation of the object.It uses the most expressive syntax available to accomplish that.function update(obj) { return { ...obj, ...