I'm new to javascript, trying to understand global and local variables. I keep hearing "Avoid global variables". I have a bunch of string variables that are only used in one function, so it I should make them local, right? I never need to change there value, so I was wondering... Every time I call the function, does that mean all those variables get set again and again, to the same value. Does it take javascript any time or effort to set these variables over and over again? Is there are better way to handle variables that you know will never change value. Here's what I'm getting at...
function test() {
var a="the quick brown fox blah blah blah...";
var b="Hello world blah blah blah....";
var c...
var d.... etc, etc....
<more code goes here>
}
To me it looks like every time I call test() all the variables get set again. If I put them outside the function wouldn't they only get set once? But that would make them global, right?