Skip to content

Technology Quote by Eric Freeman

“If you assign a new variable without using the var keyword, that variable will be global, even if you are first assigning it in a function.” quote by Eric Freeman
Download Open image
““If you assign a new variable without using the var keyword, that variable will be global, even if you are first assigning it in a function.””

Eric Freeman

About This Quote

Source Book: Head First Java, 2003

Declaring a variable without a keyword makes it global, even when done inside a function.

In simple terms: Missing var makes a variable global.

Key Takeaway

Always declare variables with var/let/const.

Themes

programming scope variables

Mood

cautious analytical

Type

technical educational

When to use this quote

  • function definitions
  • module scripts
  • debugging
  • code reviews

Key Concepts

JavaScript global scope variable declaration

Questions to Reflect On

  • Do you always declare variables explicitly?
  • How could a global variable affect other parts of your code?
A Different Perspective

Using globals can cause unexpected side effects and harder maintenance.

4.1 out of 5 (7 ratings)

More by Eric Freeman

Explore all 90 Eric Freeman quotes

More Technology quotes

Browse all 12,247 Technology quotes