English Reference

Word

local variable

Definition

compound. a piece of information in a computer program that only exists inside one specific part, like a single function. Once that part of the code finishes running, the information is forgotten.

compound. a variable declared within a specific block of code, such as a function or subroutine, which is only accessible within that scope. It is typically deallocated from memory once the execution of that block concludes.

Examples

“The program uses a local variable to store the user's current score.”

“Because the counter is a local variable, it resets to zero every time the function is called.”

“Developers prefer using a local variable over a global one to prevent unintended side effects and ensure that data remains encapsulated within the relevant logic block.”

Examples

simple

“The program uses a local variable to store the user's current score.”

contextual

“Because the counter is a local variable, it resets to zero every time the function is called.”

complex

“Developers prefer using a local variable over a global one to prevent unintended side effects and ensure that data remains encapsulated within the relevant logic block.”

Usage

Commonly used in the context of computer science and software engineering.

Pitfall

accessing the local variable from another function

passing the local variable as an argument

A local variable cannot be seen or used by code outside of the specific block where it was created.

Etymology

A compound of the adjective local, derived from the Latin locus meaning place, and the noun variable, from the Latin variare. The term emerged as a standard distinction in early programming languages to differentiate scope from global counterparts.

Etymology adapted from Wiktionary, available under CC BY-SA 4.0.

Domain

Programming

This entry

Exam level
CambridgeCambridgeCambridge English QualificationsThe exam suite from Cambridge University Press & Assessment, from A1 Movers up to C2 Proficiency. The benchmark names double as CEFR labels.C1 AdvancedIELTSIELTSInternational English Language Testing SystemThe 0–9 band test co-owned by the British Council, IDP, and Cambridge. Used for university entry, work, and migration.7.0–8.0TOEFL iBTTOEFL iBTTest of English as a Foreign Language, Internet-Based TestETS's academic English test, the standard route for US university admissions. Scored 0–120, with a 1–6 scale since 2026.1–6 scale: 5.0–5.595–113TOEICTOEICTest of English for International CommunicationETS's workplace English test, big in Japan and Korea. Listening & Reading scores 10–990 and tops out at C1.945–990EikenEikenTest in Practical English ProficiencyThe English proficiency test from the Eiken Foundation of Japan, widely taken by Japanese students. Grades run from 5 to 1, with Pre-1 and Pre-2 between them.Grade 1
Level
C1 · Advanced
Updated

QR code

englishreference.com/q/local-variable

English Reference