0
var fetchResults = tx.executeSql("SELECT * FROM sessions WHERE sessions.dayid=1 ORDER BY sessions.starttime ASC", [],
        function(tx, data){
            processorFunc(data);
            var contxt = "";
            for (var numb = 0; numb < data.rows.length; numb++) {
                contxt += data.rows[numb].title + "=" + data.rows[numb].startTime + "=" + 
                        data.rows[numb].endtime + "=" + data.rows[numb].type + "\n";
            }
            console.log(contxt);
            contxt = "";
            for (var numb in data.rows) {
                contxt += data.rows[numb].title + "=" + data.rows[numb].startTime + "=" + 
                        data.rows[numb].endtime + "=" + data.rows[numb].type + "\n";
            }
            console.log(contxt);
        });

In console, I see that for-in loop returns two more lines and all elements are undefined. I use Web Sql API here. enter image description here

Does anybody know why this will happen?

Fen
  • 1
  • 3
  • Please put your code in your question as text instead of linking to a tiny screenshot. – Ry- Mar 03 '17 at 19:28
  • How can I edit it? I don't see any button – Fen Mar 03 '17 at 19:29
  • It should be under your question’s tags. – Ry- Mar 03 '17 at 19:31
  • The part of the linked answer that applies to your case here is likely *“In addition, if any monkey patches or shims are put into place on the array object, they can show up here.”*, and you can confirm that by logging `numb` each time around the loop. – Ry- Mar 03 '17 at 19:42
  • got it, thanks, though don't fully understand :P – Fen Mar 03 '17 at 19:57
  • If you add a `console.log('Got a key:', numb);` inside your second loop, it’ll probably be clearer: some things that aren’t numbers should be logged. – Ry- Mar 03 '17 at 20:27

0 Answers0