insert
Description
Adds a key and a value to an object.
Input / Parameter
Name | Description | Input Type | Default | Options | Required |
---|---|---|---|---|---|
data | The reference object to be updated. | Object | - | - | Yes |
attribute | The key to be added to the object. | Text | - | - | Yes |
value | The value of the key. It can be null. | Any | - | - | No |
Output
Description | Output Type |
---|---|
Returns the updated object. | Object |
Example
In this example, we will insert a new key and value to an object and print the updated object in the console.
Steps
Drag a
button
component into the canvas and open theAction
tab. Select thepress
event of the button and drag theLog.write
function to the event flow.Call the function
Object.insert
inside theLog.write
function.Then call the function
Conversion.toObject
inside thedata
parameter of theObject.insert
function.Sample parameters are shown in the picture below.
Result
The console will print the updated object.
For this example, the value printed will be
{age: '27', name: 'John', job: 'Sales'}
.
Links
Related Information
See also:
Functions
Last updated