setAttribute
Last updated
Last updated
Sets an object’s attribute.
object
The object to set attribute for.
Object
-
-
Yes
attribute
The attribute to set.
String
-
-
Yes
value
The value to set for the attribute.
Any
-
-
Yes
Returns true or false.
Boolean
In this example, we will add new attribute to an object and check the resulting object in the console.
Drag a button
component into the canvas and open the Action
tab. Select the press
event of the button.
Drag the Variable.set
function to the event flow and change it's name
param value to originalObject
, and it's value
param type to funtion / subflow. Inside value
subflow add Conversion.toObject
function and add two new paremeter value1
and value2
with their value as val1
and val2
.
Back to the main flow add the Object.setAttribute
function, on it's attribute
and value
param add newValue
as a value for both of them and change it's object
parameter type to a function / subflow, inside it drag a Variable.get
function and then fill it's name
param value with originalObject
.
Back to the main flow add the Log.write
function and change it's value
parameter type to a function / subflow, inside it drag a Object.getAttribute
function and then fill it's attribute
param value with newValue
as for it's object
param, change the param type into a function / subflow and add the Varable.get
function inside, on it's name
param add originalObject
as the value.
This steps will show us the updated object attribute based on it's new parameter and value on the console.
See also