Question: Here's the scenario.

* I'm storing users as a key/value pair. The keys are the user Id's

{
'111': USER\_OBJECT,
'222': USER\_OBJECT
}

I would like to remove the first item ('111') and pass the rest of the items to my store.

Here's what works.

```
const value = The example user object;
delete value['111']
// Outcome
value = {
  '222': USER_OBJECT
}

```

I know the below method works when you know the keys:

```
const value = {name: 'test', lastName: 'last', id: '111'}
const { name, ...other} = value;
// Outcome
other = {lastName: 'last', id: '111'}

```

When I try this pattern on an object where the keys are unknown, it doesn't work:

```
const id = '111';
const value = The example user object;
const { [id], ...other} = value;
// Expected outcome
other = {
  '222': USER_OBJECT
}

```

Is this possible to do or is delete the best option?

Answer: 
(Note that this is all JavaScript, and only has to do with TypeScript to the extent that you're using the TypeScript compiler for [downleveling](https://www.typescriptlang.org/docs/handbook/2/basic-types.html#downleveling), but such would equally well apply to [Babel](https://babeljs.io/) or any other JavaScript downleveler.)

In an [object destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#object_destructuring), you need to specify both the name property from the object and the name of the variable you'd like to assign the property to. Generally this is the same name, but you cannot do this with a *computed* property name, since (without `eval` or other craziness) variable names must be declared statically and not dynamically. Thus, you will have to pick a new name for your property.

Since all you're doing is discarding that property in order to make use of the rest properties, you can just pick a valid identifier name that you don't care about, like this:

```
const { [id]: _, ...other } = value;

```

[Playground link to code](https://www.typescriptlang.org/play?#code/MYewdgzgLgBAqgZQKICUD6B5AQgKSQYQBUYBeGAbwF8AoUSWANwEMAbAVwFNSKYByARkG8AXPGTpseIgBo+AJgUixqTLgLEadaDACWAE24ChAblrht5GAG19AXVFpZAOhcgoACw4AnGJW7N2DlMtEBYOJxYQAHMACjdPLwBKIA)
I assume your user data is stored as a dictionary, like this:

```
let userData = {'111': {...}, '222': {...}, ...};

```

If you want to filter a specific ID, you can use:

```
Object.keys(userData)
    .filter(id => id !== '111')
    .reduce((acc, cur) => ({...acc, [cur]: userData[cur]}), {})

```

First, we filter out the excluded value, and then, reconstruct the userData object.

If you want to filter by a `knownIDs` array, use:

```
Object.keys(userData)
    .filter(id => knownIDs.include(id))
    .reduce((acc, cur) => ({...acc, [cur]: userData[cur]}), {})

```