Combines the items of two objects into one.
| Type | Value |
| Input | Obj<Any> | an object |
| other (param #1) | Obj<Any> | another object |
| Output | Obj<Any> | an object with the items of the input and other |
Where the input and other share keys, the values of other are used in the output.
| Program | Type | Value | Error |
{a: 1} +{b: 2} | Obj<> | {a: 1, b: 2} | |
{a: 1, b: 2} +{b: 3} | Obj<> | {a: 1, b: 3} | |
Retrieves the value of a given property.
| Type | Value |
| Input | Obj<<A Any>> | an object |
| prop (param #1) | Str|Num | a property key |
| Output | <A Any> | the value associated in the input object with the given property key |
| Program | Type | Value | Error |
{} get("a") | Void | | {"Code":"VoidProgram","Kind":"Type"} |
{a: 1} get("a") | Num | 1 | |
{a: 1, b: "hey"} get("a") | Num|Str | 1 | |
{a: 1, b: "hey", c: false} get("a") | Num|Str|Bool | 1 | |
{1: "a"} get(1) | Str | "a" | |
{1.5: "a"} get(1.5) | Str | "a" | |
{b: 1} get("a") | Num | | {"Code":"NoSuchProperty","GotValue":"\"a\"","Kind":"Value"} |
Checks for the presence of a given property.
| Type | Value |
| Input | Obj<<A Any>> | an object |
| prop (param #1) | Str|Num | a property key |
| Output | Bool | true if the object has the given property, false if not |
| Program | Type | Value | Error |
{} has("a") | Bool | false | |
{a: 1} has("a") | Bool | true | |
Iterates over the properties together with the values.
| Type | Value |
| Input | Obj<<A Any>> | an object |
| Output | Arr<Arr<Str, <A Any>>...> | an array of tuples of the properties and associated values of the input object |
| Program | Type | Value | Error |
{a: 1, b: 2} items sortBy(@0, <) | Arr<Arr<Str, Num>...> | [["a", 1], ["b", 2]] | |
{} items | Arr<Arr<Str, Void>...> | [] | |
Lists the properties of an object.
| Type | Value |
| Input | Obj<<A Any>> | an object |
| Output | Arr<Str...> | all the property keys of the object, as an array |
| Program | Type | Value | Error |
{a: 1, b: 2} props sort | Arr<Str...> | ["a", "b"] | |
{} props | Arr<Str...> | [] | |
Lists the values of an object.
| Type | Value |
| Input | Obj<<A Any>> | an object |
| Output | Arr<<A Any>...> | all the property values of the object, as an array |
| Program | Type | Value | Error |
{a: 1, b: 2} values sort | Arr<Num...> | [1, 2] | |
{} values | Arr<> | [] | |
Removes a property from an object.
| Type | Value |
| Input | Obj<<A Any>> | an object |
| prop (param #1) | Str | a property key |
| Output | Obj<<A Any>> | the input object, but with the specified property removed |
| Program | Type | Value | Error |
{a: 1, b: 2} without("b") | Obj<Num> | {a: 1} | |
{a: 1, b: 2} without("c") | Obj<Num> | {a: 1, b: 2} | |