setAttribute
Description
Sets an object’s attribute.
Input / Parameter
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
Output
Returns true or false.
Boolean
Example
In this example, we will add new attribute to an object and check the resulting object in the console.
Step
Drag a
button
component into the canvas and open theAction
tab. Select thepress
event of the button.Drag the
Variable.set
function to the event flow and change it'sname
param value tooriginalObject
, and it'svalue
param type to funtion / subflow. Insidevalue
subflow addConversion.toObject
function and add two new paremetervalue1
andvalue2
with their value asval1
andval2
.Back to the main flow add the
Object.setAttribute
function, on it'sattribute
andvalue
param addnewValue
as a value for both of them and change it'sobject
parameter type to a function / subflow, inside it drag aVariable.get
function and then fill it'sname
param value withoriginalObject
.Back to the main flow add the
Log.write
function and change it'svalue
parameter type to a function / subflow, inside it drag aObject.getAttribute
function and then fill it'sattribute
param value withnewValue
as for it'sobject
param, change the param type into a function / subflow and add theVarable.get
function inside, on it'sname
param addoriginalObject
as the value.
Result
This steps will show us the updated object attribute based on it's new parameter and value on the console.
Related Information
See also
Last updated