set

Assigns new key-value pairs to a map object

(set keyValuePairs obj)

Returns

The set function returns a new map object with the updated key-value pairs. The original map object remains unchanged

Parameters

keyValuePairs (object) - an object containing the key-value pairs to be added or modified in the map

obj (object) - the target map object to which the key-value pairs will be assigned.

  • The set function assigns new key-value pairs to a map object

  • It creates a new map with the updated values and does not modify the original map.

  • The function takes a target map object and an object containing key-value pairs to be added or modified.

  • The resulting map contains the original key-value pairs along with any new or modified pairs

Examples

(def obj1 {age: 22})
(set {height: 100} obj1)
;;=> {age: 22, height: 100}

obj1    ;; obj remains unchange
;;=> {age: 22}

Was this helpful?