September 9th, 2013, 10:52 AM
Well, I see how to do everything, but the question is what truely is needed. If a variable doesn't exist, MUST you declare it via 'var varname'? Or is it ok to declare by assigning a value like 'varname = "Some value."'?
He who knows not and knows not he knows not: he is a fool - shun him. He who knows not and knows he knows not: he is simple - teach him. He who knows and knows not he knows: he is asleep - wake him. He who knows and knows he knows: he is wise - follow him
September 9th, 2013, 11:27 AM
Unless you declare a variable using the var keyword, then you are not actually working with a variable. Rather, what happens is you just end up implicitly creating a new property on the global object (window). In most cases, it looks and feels the same as a variable, but there is a technical difference between the two situations.
You should always declare your variables using var blah to prevent scope issues and prevent mucking up the global object with unnecessary properties
Comments on this post
Last edited by kicken; September 9th, 2013 at 03:34 PM.
Recycle your old CD's, don't just trash them
If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud