TOPICS TO COVERED:
2)List
3)Map
4)Set
Let's discuss in detail,
1)Array
To define the attribute for storing array values we can write:
<aura:attribute type="String[]" name="arrayattribute" default="['Apple','Orange','Mango']" />
- Here we are storing some default values in "arrayattribute".
- An array is a collection of the defined data types.
- Setting a default value without square brackets is deprecated and can lead to unexpected behavior.
2)List
To define the attribute for storing values in order we can write:
<aura:attribute type="List" name="Listattribute" default="['Apple','Orange','Mango']" />
- Here we are storing some default values in "Listattribute".
- The list can have duplicates as well.
- Setting a default value without square brackets is deprecated and can lead to unexpected behavior.
3)Map
To define the attribute for mapping keys to values.
<aura:attribute type="Map" name="Mapattribute" default="{1:'value1',2:'value2'}" />
- Here we are storing some default values in "Mapattribute".
- A map cannot have duplicate keys.
- A collection maps keys to values. Each key can map to at most one value. Defaults to an empty object, {}.
- Retrieve values by using cmp.get("v.Mapattribute")['1'].
4)Set
To define the attribute for Values which are unique.
<aura:attribute type="Set" name="Setattribute" default="['Apple','Orange','Mango']" />
- Here we are storing some default values in "Setattribute".
- The set cannot have duplicate values.
- Order for the set item is not as it is when values are returned, It may be in the same order or may change.
- Setting a default value without square brackets is deprecated and can lead to unexpected behavior.
nice explanation
ReplyDeletePlease post new blogs also...we are extremely reading your blogs... well explained
ReplyDeleteHello mate greeat blog
ReplyDelete