You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The proposed key exclusion syntax enhances the flexibility and clarity of object spread operations. Its ability to handle dynamic keys, complex expressions, strings with spaces, and symbols makes it a robust tool for JavaScript developers. By eliminating unnecessary object copies or deletions, it also provides performance benefits in large-scale applications.
262
231
263
232
Contributions and feedback are welcome!
233
+
234
+
## Graveyard
235
+
236
+
### Excluding Multiple Keys Dynamically
237
+
You can exclude an array of keys using the spread operator within the exclusion syntax:
238
+
239
+
```js
240
+
constsanitizedOpts= {
241
+
...a,
242
+
-[...keysToExclude], // Excludes all keys in the `keysToExclude` array
243
+
...b,
244
+
};
245
+
```
246
+
247
+
Desugared:
248
+
```js
249
+
constsanitizedOpts= (() => {
250
+
const_$1= {};
251
+
for (constkeyin src) _$1[key] = src[key];
252
+
for (constkeyof keysToExclude) delete_$1[key]; // Remove dynamic keys
0 commit comments