Question Bank

JavaScript Immutable Object Key Removal: Two Approaches Quiz

Difficulty: Easy

Two seeded approaches to remove an object key without mutation (spread + delete, reduce + filter), plus two companions on destructure-and-drop and a deep-clone caveat.

Question Bank
/

JavaScript Immutable Object Key Removal: Two Approaches Quiz

JavaScript Immutable Object Key Removal: Two Approaches Quiz

Two seeded approaches to remove an object key without mutation (spread + delete, reduce + filter), plus two companions on destructure-and-drop and a deep-clone caveat.

Question Bank
Easy
JavaScript
4 questions
quiz
references
immutability
js-spread-rest

1,150 views

26

Implement removeItem(obj, key) that returns a NEW object with the given key removed and the original object untouched. Use reduce over Object.keys and skip the target key.

Examples

Example 1:

Input: { color: 'red', model: '1980', owner: 'john doe' }, 'owner'
Output: { color: 'red', model: '1980' }
Explanation: A new object is returned; the original `owner` field is dropped, and the input object is unchanged.