Myna.Query undefined

Skip to first unread message

Tony Zakula

Nov 28, 2010, 7:05:15 PM11/28/10
to mynajs-general
I have the code below. and the output that it produces. There are
only fourteen records in the db, and no empty records as I have a
primary key and every record has a code value.

I was wondering what may be causing those undefined values to be in
the object as it causes problems when mapping codes to other


Tony Z

function setAppSettings() {
var x;
var obj;
var i = 0;
var qry = new Myna.Query({
sql:"select * from setting"});
if ( > 0) {
for (x in {
obj =[x];
i += 1;
Myna.println(i + " " + obj.code);



1 undefined
2 siteTheme
3 undefined
4 appDirectory
5 seoFileExtension
6 seoProductMarker
7 seoPageMarker
8 storeName
9 customerURL
10 secureCustomerURL
11 administratorURL
12 charset
13 cachecontrol
14 expires
15 robots
16 headerLinks

Mark Porter

Nov 29, 2010, 12:35:41 PM11/29/10
The problem is using "for (x in array)" syntax. That will loop over
every property in the array, not just the numeric ones. What you want
to use here is Array.forEach like so:,i){

i += 1;
Myna.println(i + " " + obj.code);


As a bonus, because "obj" and "i" are now local argument variables
there is no need to "var" them at the top of the function.
Mark Porter

Myna JavaScript Application Server
Easy web development with server-side JavaScript

> --
> You received this message because you are subscribed to the Google Groups "MynaJS-General" group.
> To post to this group, send email to
> To unsubscribe from this group, send email to
> For more options, visit this group at

Tony Zakula

Nov 29, 2010, 1:00:38 PM11/29/10
Ah, thanks. Still climbing the JavaScript curve I guess. :-)

Tony Zakula

Reply all
Reply to author
0 new messages