Like in many scripting languages, Lua has variables. You can think of a variable as something that stores values. When you apply a value to a variable, you can refer to it using the same variable name.
An application consists of comments, blocks, statements, and variables. A comment is never processed, but it is included to explain the purpose of a statement or block. A block is a group of statements. Statements provide instructions on what operations and computations need to be done; variables store the values of these computations. Setting a value in a variable is called assignment.
Lua uses three kinds of variables, which are as follows:
Global variables
Local variables
Table fields (properties)
Variables take up memory space, which can be limited on various mobile devices. When a variable is no longer required, it is best to set its value to nil so that it can be cleaned quickly.