Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ![]() Interested in joining? Click here. If you are already a member of ZBCode, feel free to login right here: |
| Interesting... | |
|---|---|
| Tweet Topic Started: Jul 11 2009, 10:43 PM (233 Views) | |
| Reid | Jul 11 2009, 10:43 PM Post #1 |
![]()
What? The land of the free? Whoever told you that was your enemy.
![]()
|
Most people throw around the var keyword when coding javascript, but it has more significance than you may think. In regular browsers, the keyword is fairly useless, but in the JS standard, look at this: That's right. After you execute a function where you stuck a value in an undefined variable--i.e. didn't use the var keyword first--you have created a global unknowingly! Surprising, isn't it? Quite frankly, most people omit the 'var' keyword a lot - but for you sticklers out there like Choco, if you're looking to avoid globals, don't forget the keyword! The general rule: if a variable isn't defined already, use the 'var' keyword. Remember the shortcut on the keyword as well: Just thought I'd bring this to light. ![]() |
| The Resource Board | |
![]() |
|
| Dorith | Jul 12 2009, 12:42 AM Post #2 |
![]()
Has just entered the Matrix
![]()
|
Err... what does global mean exactly? Sorry for intruding on this "high leveled" coding skilled thread... |
![]() (Made emoticon using Codes Rock's Smiley Generator) | |
![]() |
|
| Reid | Jul 12 2009, 12:35 PM Post #3 |
![]()
What? The land of the free? Whoever told you that was your enemy.
![]()
|
Global variables exist all throughout a page. That's the lesson on scope.
|
| The Resource Board | |
![]() |
|
| Vitality | Jul 12 2009, 02:09 PM Post #4 |
|
Tabula Rasa
![]()
|
Hehehe Reid and your scope Cool to know though, thanks.
|
![]() |
|
| Kevin | Jul 12 2009, 02:52 PM Post #5 |
![]()
|
This topic is beyond the scope of my brain. ![]() That's actually quite interesting. Though I never really work with JS, I always sort of wondered what the significance of using var was.
|
| |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Code University · Next Topic » |



















Cool to know though, thanks.

7:46 PM Jul 10