Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting an undefined out of the array 1

Status
Not open for further replies.

Anml4ixoye

Programmer
Nov 6, 2000
1
US
Hello!

I am using the following code to cycle through the objects in an array I have established:

Code:
function listGlosNames(obj) {
 var names = "";
 for(var i in obj) names += &quot;<a href='test.htm?key=&quot; + i + &quot;'>&quot; + i + &quot;</a><br>&quot;;
 document.write(names);
}

When I call the function from the code, it writes all of the objects but then includes an undefined at the bottom of the list. In a further test, I added an alert to the end of the function after document.write(names). The alert pops up after the last object is written, but before the undefined. Once you click on Ok, the undefined is written to the page.

Anyone have any thoughts? I'm probably overlooking something simple, but we can't seem to get it. Thanks!

Cory
 
if(typeof(i)!=&quot;undefined&quot;)
will let you know whether a particular i is undefined... i have found for in bugs before jared@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top