September 9th, 2013, 11: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 that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.
September 9th, 2013, 12:27 PM
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 04: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