Wednesday, September 5, 2018

Collection types in Salesforce Lightning

Basically,We have the below collection type available in lightning component.

1)Array
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']" />

Note:>Here we are storing some default values in "arrayattribute".
        >Array is a collection of defined data type.


2)List:


To define the attribute for storing values in order we can write:

<aura:attribute type="List" name="Listattribute" default="['Apple','Orange','Mango']" />

Note:>Here we are storing some default values in "Listattribute".
         >List can have duplicates as well.


3)Map:


To define the attribute for mapping keys to values.

<aura:attribute type="Map" name="Mapattribute" default="{1:'value1',2:'value2'}" />

Note:>Here we are storing some default values in "Mapattribute".
         >Map cannot have duplicate key.


4)Set:


To define the attribute for Values which are unique.

<aura:attribute type="Set" name="Setattribute" default="['Apple','Orange','Mango']" />

Note:>Here we are storing some default values in "Setattribute".
         >Setcannot have duplicate Values.
         >Order for set item is not as it is when values are returned,It May be in same order or may change.
**************************************************************************************************************

No comments:

Post a Comment