Description
Creates a new map with a single specified key removed. The original map is not modified.Syntax
Parameters
Returns
Type: map (object) A new map containing all properties from the input map except the specified key. Returns an empty map if input is not a valid object.Examples
Example 1: Basic Key Removal
Example 2: Removing Sensitive Data
Example 3: Cleaning Response Data
Example 4: Removing Non-Existent Key
Notes
- Returns empty map if input is not a valid object or is
null - If key is
null, returns a shallow copy of the map - If the key doesn’t exist, returns a copy with all original properties
- Creates a new map; does not modify the original
- Useful for sanitizing data, removing sensitive fields, or filtering properties
See Also
- map.removeKeys - Remove multiple keys at once
- map.submap - Keep only specific keys (inverse operation)
- map.merge - Combine multiple maps
Frequently Asked Questions
Does flex.map.removeKey modify the original map?
Does flex.map.removeKey modify the original map?
No. It returns a new map with the specified key removed, leaving the original unchanged.
What happens if the key does not exist?
What happens if the key does not exist?
The function returns a copy of the original map unchanged — no error is thrown.