🔥
CS1334
  • Introduction to Programming
  • Algorithm
  • RGB Colormode
  • HSB Colormode
  • Animation
  • Contrasting Concepts - Art
  • Geometric Transform Functions
    • Animation Using Transforms
  • Functions to Draw Characters
  • Functions to Draw Flowers
  • Bounding Box Conditional Branching
  • Canvas Border Constraints
  • Loops Using Math Formulas for Position
  • Finite State Machine
  • Arrays
  • KeyPress Logic
  • Time
  • Collision between objects
  • Buttons
  • Scene Management - State Variables
  • Project 3 - Animation Specification - FSM
  • Project 4 - Animation Logic
  • Project 5
  • Javascript Syntax
    • Variables
    • Indentifiers
    • Functions
    • Variable Scope: Global or Local
    • Logical Operators
    • Numerical Operator Shortcuts
    • Repetition - Loops
Powered by GitBook
On this page

Was this helpful?

  1. Javascript Syntax

Variable Scope: Global or Local

Variable Scope refers to the location in code where variables can be used in a program.

Global Variables Variables defined outside any functions are visible and usable throughout the program - in any code below where they have been declared.

Local Variables: If a variable is defined as part of a function definition, then the variable belongs to that function. The variable has local-scope. The variable is only visible within that function, when that function is being executed, when the function has completed execution, the local-variables no longer exist.

Local Variables Hide Global Variables within a function Within a function's definition, if a local variable has the same name as a global variable, the global variable is hidden by the local variable, this is global variable hiding. Local variables have higher status than global variables within a function.

PreviousFunctionsNextLogical Operators

Last updated 5 years ago

Was this helpful?