Thread
:
global vs local-Please help to understand the principle
View Single Post
01-30-2013, 04:22 PM
PM User
|
#
5
sunfighter
Senior Coder
Join Date: Jan 2011
Location: Missouri
Posts: 2,396
Thanks: 18
Thanked 351 Times in 350 Posts
I have always used "window" to get my globals. Your code would therefore be:
Code:
var a = 123; function f() { alert(window.a); var a = 1; alert(a); } f();
sunfighter
View Public Profile
Find More Posts by sunfighter