insert
Description
Adds a key and a value to an object.
Input / Parameter
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
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
buttoncomponent into the canvas and open theActiontab. Select thepressevent of the button and drag theLog.writefunction to the event flow.Call the function
Object.insertinside theLog.writefunction.Then call the function
Conversion.toObjectinside thedataparameter of theObject.insertfunction.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