Attributes are declared in a component's markup. You can treat attributes as similar to Java variables or JavaScript variables. To extract the values from them, we use component.get(), and to set the values, we use component.set().
Let's suppose that you have defined an attribute for a component using aura:attribute, as follows:
<aura:component access="global">
<aura:attribute name="searchTerm" type="String" />
</aura:component>
You can get the value of the attribute by using the following:
component.get("v.searchTerm")
To set the value of the attribute, the syntax is as follows:
component.set("v.searchTerm",'Lightning')
Here, Lightning is the value of the attribute that we are setting.