redho home | products | services

Programming Forums


Community for Java, PHP, Perl C, ASP and Python programmers

Ask your IT question here

the array is still empty


Goto page 1, 2  Next
 
Post new topic   Reply to topic    Programming Forums -> JavaScript forum
View previous topic :: View next topic  
Author Message
froomzer
Enthusiastic Coder


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.

Reply with quote
 
AmeliaR
Enthusiastic Coder


Joined: 31 May 2006
Posts: 142
Anything defined outside of the functions is global
Anything non-local

Reply with quote
 
Peter Pitt
Enthusiastic Coder


Joined: 20 May 2006
Posts: 114
Location: Egypt
As is anything without the var keyword
Reply with quote
 
BigDaddy
Enthusiastic Coder


Joined: 26 May 2006
Posts: 147
Heh
Globals should be defined in global scope, not by omitting the var keyword.
Declared*

Reply with quote
 
froomzer
Enthusiastic Coder


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?

Reply with quote
 
Mupolan
Enthusiastic Coder


Joined: 30 May 2006
Posts: 101
Of course
Reply with quote
 
froomzer
Enthusiastic Coder


Joined: 23 May 2006
Posts: 148
I'm getting "unterminated string literal" errors.
I put the string back on one line, it goes away.

Reply with quote
 
Jackil
Enthusiastic Coder


Joined: 24 May 2006
Posts: 97
Use \n
Or <br> if it's html

Reply with quote
 
froomzer
Enthusiastic Coder


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.
Reply with quote
 
BigDaddy
Enthusiastic Coder


Joined: 26 May 2006
Posts: 147
\
"bleh\
Moo";

Reply with quote
 
Page 1 of 2 Goto page 1, 2  Next
Post new topic   Reply to topic    Programming Forums -> JavaScript forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group