Category: Objects Kind: Operation Description: Construct a key-value pair
Name | Abbreviation | Type | Access | Description |
---|---|---|---|---|
Key | K | String | Item | The key of the pair |
Value | V | Any | Item | The value of the pair |
Name | Abbreviation | Type | Access | Description |
---|---|---|---|---|
Pair | P | Object | Item | The constructed key-value pair |
A key-value pair is a fundamental concept in programming and data storage, especially in dictionaries, maps, JSON, and databases.
A key-value pair consists of:
Think of a dictionary (the book):
If you look up the key "apple"
in the dictionary, the value might be "a fruit that grows on trees"
.
Take, for example, a real estate listing. It might be stored like this:
property_listing = {
"address": "123 Maple Street",
"price": 450000,
"bedrooms": 3,
"bathrooms": 2,
"square_feet": 1800,
"status": "For Sale"
}
Breakdown of key-value pairs:
KEY | VALUE |
---|---|
address | 123 Maple Street |
price | 450000 |
bedrooms | 3 |
bathrooms | 2 |
square_feet | 1800 |
status | For Sale |
Each key describes a property attribute, and each value holds the actual data about it.
This kind of structure is super common in databases, and APIs—makes it easy to store, access, and filter lists.
Object entries refer to the key-value pairs within an object. In JavaScript (and similar structures like JSON), these are called entries because each one is a single unit of information: a key and its corresponding value.
Let’s say you have a JavaScript object:
javascript
CopyEdit
const property = {
address: "123 Maple Street",
price: 450000,
bedrooms: 3
};
The entries of this object are:
["address", "123 Maple Street"]
["price", 450000]
["bedrooms", 3]
Feed in a string to define the key or name of the property
You can use a string, panel, or the result of any other node that outputs a string
Feed in any data type as the “value”
The result is a key-value pair object