| View previous topic :: View next topic |
| Author |
Message |
froomzer
Joined: 23 May 2006 Posts: 148
|
| I defined an empty array in my .js, inside of a function I stick some things in there, call the function, and the array is still empty. Is there some bizarre scoping going on here? I didn't think js had a 'global' statement. |
| |
|
|
|
|
AmeliaR
Joined: 31 May 2006 Posts: 142
|
Anything defined outside of the functions is global
Anything non-local |
| |
|
|
Peter Pitt
Joined: 20 May 2006 Posts: 114 Location: Egypt
|
| As is anything without the var keyword |
| |
|
|
BigDaddy
Joined: 26 May 2006 Posts: 147
|
Heh
Globals should be defined in global scope, not by omitting the var keyword.
Declared* |
| |
|
|
froomzer
Joined: 23 May 2006 Posts: 148
|
That was my understanding, too. But I've got the function logging as it sticks things in and the next line of code tries to pull something out and gets nothing.
Well, having confirmed there isn't something bizarre happening with scoping, I'm thinking it's a problem with array identifiers and will go away as I whittle this down to a minimal example.
Argh, yeah. The identifier I was sticking into the array with was undefined due to typo. Thanks, folks.
Is it possible to have a multi-line string? |
| |
|
|
Mupolan
Joined: 30 May 2006 Posts: 101
|
| Of course |
| |
|
|
froomzer
Joined: 23 May 2006 Posts: 148
|
I'm getting "unterminated string literal" errors.
I put the string back on one line, it goes away. |
| |
|
|
Jackil
Joined: 24 May 2006 Posts: 97
|
Use \n
Or <br> if it's html |
| |
|
|
froomzer
Joined: 23 May 2006 Posts: 148
|
| I want the string to span multiple lines of source code so I can read it, I'm not trying to whitespace output. |
| |
|
|
BigDaddy
Joined: 26 May 2006 Posts: 147
|
\
"bleh\
Moo"; |
| |
|
|
| Page 1 of 2 |
Goto page 1, 2 Next |
|