Variables provide a place in your app to store temporary data until you need to display or read it or send it somewhere else, for example, to a back-end system.
For example, let's consider that you have an application that is a calculator. You will need to store the operands (the numbers the user enters to be added or multiplied) and the result of the calculation. Once the data is stored in a variable, you can display the answer in a text field so the user can see the result.
You can use the variables to store:
- Data retrieved from an external data resource.
- Information about the current user (such as name, E-mail).
- User’s preferences for the app while the app is running (such as preferred home page, favorite baseball team).
- Information about the current product that is being displayed on the current page.