Variable
Переменная
A variable gives a piece of data a name so code can read and use it. Depending on the language and how the variable is declared, the name may be assigned a new value later.
What a variable does
A variable lets you use a meaningful name such as remainingSeats instead of repeating a number or recalculating it every time you need it. When a booking goes through, the program can update that variable. The next line that reads remainingSeats gets its current value, not the value it had when the program started.
Declaration, assignment, and scope
A declaration introduces a name. Initialization gives it a starting value. The two often share a line, as in JavaScript's let remainingSeats = 12. A later assignment can replace that value: remainingSeats = remainingSeats - 1 reads the old count, subtracts one, and assigns the result back. The = sign performs an assignment here; it does not ask whether two expressions are equal.
Scope is the part of the code where a name can be used. A JavaScript let declared inside a block is not accessible outside that block. If an inner block declares a name that already exists in an outer block, the inner declaration shadows the outer one. The two are separate variables, so assigning to the inner one does not update the outer one.
A variable's type rules depend on the language. A Java int variable cannot be assigned a string. In Python, the same name can refer to an integer at one point and a string later. The objects still have types; rebinding a name does not convert the original object.
Example: two names, one list
waiting = ['Sam']
backup = waiting
waiting.append('Lee')
print(backup) # ['Sam', 'Lee']
waiting = []
print(backup) # ['Sam', 'Lee']
backup = waiting does not copy the list. Both names refer to the same list, so append changes what you see through either name. The final assignment is different: it makes waiting refer to a new empty list while backup still refers to the original. If you want a separate list containing the same elements, use waiting.copy() at the point where you need the copy. For a list of strings that's enough; a shallow copy still shares any nested mutable objects.
In everyday code and interviews
Variables hold function inputs, intermediate results, loop counters, and application state. Choose names that tell readers what the value represents: timeoutMs is more useful than t when units matter. Keep variables local when they are only needed in one function or block, so readers do not have to search unrelated code for assignments.
In interviews, you may be asked to predict the output of a few lines. Track which declaration each name refers to, then distinguish assigning a new value from changing an object in place. If a language prevents reassignment, check separately whether the object itself can still change.