exclude specific key/value pairs by key name when copy contents from one object to another

The following example is working correctly, yielding the desired output. However, I’m wondering if there’s a more concise way to do this copy operation by excluding the key/value pairs for keys created and updated from the data object.

        const actionMode = 'update';        // 'create';

        const dataFromParent = {
            itemid: "104",
            itemname: "insurance",
            itemtype: "expense",
            unitofmeasure: "$/yr",
            created: "2021-04-14 05:59:30.097",
            updated: "2021-04-14 05:59:30.097"
        }

        const data = { ...dataFromParent }; // make a shallow copy to avoid changing original object values

        if (actionMode == 'update') {
            delete data.created;
            delete data.updated;
        }

        console.log(JSON.parse(JSON.stringify(dataFromParent)));
        console.log(JSON.parse(JSON.stringify(data)));

Console output: enter image description here

Using the recommendation posted by @vdegenne on 11/23/2018 in this post I tried:

let data = {};

if (actionMode == 'update') {
    data = (({ created, updated, ...o }) => o)(dataFromParent);
}

which causes a “Failed to compile” result with these errors:
enter image description here

EDIT:
This modification gives the desired result and does not have any "no-unused-vars" errors:

        let data = {};

        if (actionMode == 'update') {
            // eslint-disable-next-line no-unused-vars
            const { created, updated, ...rest} = { ...dataFromParent };
            data = rest;
        }

Answer

You could use Object destructuring so that it will assign created, updated values, and rest other properties assign in a single object.

As you are using VUE, so add the following snippet before all import in script tag in x.vue file. SEE FOR VUE

// eslint-disable-next-line no-unused-vars

Disallow Unused Variables (no-unused-vars)

If error still persist then change the ESLint config in package.json

"rules": {
   "no-unused-vars": "off"
}

const dataFromParent = {
  itemid: "104",
  itemname: "insurance",
  itemtype: "expense",
  unitofmeasure: "$/yr",
  created: "2021-04-14 05:59:30.097",
  updated: "2021-04-14 05:59:30.097",
};

const { created, updated, ...rest } = dataFromParent; // make a shallow copy to avoid changing original object values
const data = rest;

console.log(data);