Return a new object with one field changed.

Updating Objects

update_object.js
const stock = 5;
const updated = JSON.stringify({
  ...{ item: "pen", stock: 2 },
  stock: stock,
});
const available = stock > 0;

console.log("updated=" + updated);
console.log("available=" + available);
update-object Object spread can copy old fields and override one field. The replacement field appears later in the literal.